
    9 f                     H   U d Z ddgZddlmZ ddlmZ ddlmZ ddlZddl	Z	ddlZddl
ZddlZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZ ddlZdd	lmZ dd
lmZ ddlm Z  ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 dZ9ee:eee:e:f                  f         Z;ee<d<   ee:e:f         Z=ee<d<   e G d d                      Z>d Z?ej@        jA        j         ZBeCjD        j         ZEd ejF        ejG        ej@        eHfD             ZI eJeK          ZL eJe:jM                  ZNe.ZOe"jP        ZQ G d de          ZR eSeRj<        T                                          ZUd  ZVe G d! d"                      ZWe2d#d#d#d$d%e:d&eXd'eXd(eXd)eXd*eRfd+            ZYd, ZZd*ee:df         fd-Z[d:d*ee:df         fd/Z\d0 Z]e2d1             Z^e2d2             Z_e2d;d4            Z`d5 Zad*ee:         fd6Zbd7 Zc G d8 de0          Zdd*e:fd9ZedS )<zTools for inspecting Python objects.

Uses syntax highlighting for presenting the various information elements.

Similar in spirit to the inspect module, but all calls take a name argument to
reference the name under which an object is being read.
	InspectorInspectColors    )	dataclass)	signature)dedentN)	castAnyOptionalDictUnionList	TypedDict	TypeAliasTuple)page)pretty)skip_doctest)
PyColorizeopenpy)safe_hasattr)compress_user)indent)list_namespacetypestr2type)
TermColors)	Colorable)undoc)	highlight)PythonLexer)HtmlFormatter__custom_documentations__UnformattedBundleBundlec                   ^    e Zd ZU eed<   eed<   eed<   ee         ed<   eed<   eed<   d ZdS )	OInfoismagicisaliasfound	namespaceparentobjc                 "    t          | |          S )zGet a field from the object for backward compatibility with before 8.12

        see https://github.com/h5py/h5py/issues/2253
        )getattr)selffields     K/var/www/equiseq/venv/lib/python3.11/site-packages/IPython/core/oinspect.pygetz	OInfo.getK   s     tU###    N)	__name__
__module____qualname__bool__annotations__r
   strr	   r1    r2   r0   r%   r%   B   sb         MMMMMMKKK}KKK	HHH$ $ $ $ $r2   r%   c                 X    t          | t                      t          d                    S )NT)	noclasses)r   r   r    )codes    r0   pylightr=   \   s#    T;==-$*G*G*GHHHr2   c                 6    h | ]}t          j        |          S r9   )inspectgetdoc).0ts     r0   	<setcomp>rC   b   s/       GN1  r2   c                      e Zd ZU ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed	<   ee         ed
<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   ee         ed<   eed<   eed<   eed<   eed<   eed<   dS )InfoDict	type_name
base_classstring_formr)   lengthfile
definition	docstringsourceinit_definitionclass_docstringinit_docstringcall_defcall_docstring
subclassesr&   r'   isclassr(   nameN)r3   r4   r5   r
   r8   r7   r6   r9   r2   r0   rE   rE   t   s/        }#}SM
3-}SMc]"""c]"""SM!!!smSM!!! MMMMMMMMMKKK
IIIIIr2   rE   c                     | dk    r#t          j        dt          d           t          S t	          dt
          d|           )Ninfo_fieldszfIPython.core.oinspect's `info_fields` is considered for deprecation and may be removed in the Future.    
stacklevelzmodule z has no attribute )warningswarnDeprecationWarning_info_fieldsAttributeErrorr3   )rU   s    r0   __getattr__r`      sV    }t	
 	
 	
 	

 
I8IIII
J
JJr2   c                   ^    e Zd ZU dZeed<   ee         ed<   eed<   e	ed<   e
e         ed<   dS )InspectorHookDatazData passed to the mime hookr+   info	info_dictdetail_levelomit_sectionsN)r3   r4   r5   __doc__r	   r7   r
   r%   rE   intlistr8   r9   r2   r0   rb   rb      sY         &&	HHH
5/9r2   rb   F)rT   r'   r&   rU   r(   rT   r'   r&   returnc                 x    |fdt           D             | d<   |d<   |d<   |d<   |d<   t          di S )z1Make an object info dict with all fields present.c                     i | ]	}|v|d 
S Nr9   )rA   kinfodicts     r0   
<dictcomp>zobject_info.<locals>.<dictcomp>   s%    CCCA(1B1B41B1B1Br2   rU   r(   rT   r'   r&   r9   )r^   rE   )rU   r(   rT   r'   r&   kwro   s         @r0   object_inforr      si     HCCCCCCCHHVHW!HY!HY!HYhr2   c                 .   t          |           }|dS |                    d          rdS t          j                            |          sdS t          j        |d          5 }t          j        |j	                  \  }}ddd           n# 1 swxY w Y   |S )znGet encoding for python source file defining obj

    Returns None if obj is not defined in a sourcefile.
    Nz.soz.dllz.pydrb)
	find_fileendswithospathisfile	stdlib_ioopenr   detect_encodingreadline)r+   ofilebufferencoding_liness        r0   get_encodingr      s    
 cNNE }t	/	0	0 
tW^^E"" t
 ^E4(( 	GF%5foFFHf	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   !B

BBc                     	 |                                  }t          |t                    rt          j        |          S n# t
          $ r Y nw xY wt          j         |           }|S )a=  Stable wrapper around inspect.getdoc.

    This can't crash because of attribute problems.

    It also attempts to call a getdoc() method on the given object.  This
    allows objects which provide their docstrings via non-standard mechanisms
    (like Pyro proxies) to still be inspected by ipython's ? system.
    )r@   
isinstancer8   r?   cleandoc	Exception)r+   dsdocstrs      r0   r@   r@      sv    (ZZ\\ b# 	(#B'''	(    
 ^C  FMs   A   
AA c           	         t          | t                    rg }dD ]}t          | |          }|t          |          }|rd|z  nd}|                    d                    d||f                     t          j        |          r4t          |          }|r"|                    t          |                     |                    ||dt          |          d           |rd                    |          S dS t          |           } 	 t          j        |           }nP# t          $ r7 	 t          j        | j                  }n# t          t          f$ r Y Y dS w xY wY nt          $ r Y dS w xY w|S )al  Wrapper around inspect.getsource.

    This can be modified by other projects to provide customized source
    extraction.

    Parameters
    ----------
    obj : object
        an object whose source code we will attempt to extract
    oname : str
        (optional) a name under which the object is known

    Returns
    -------
    src : unicode or None

    )fgetfsetfdelNz%s.r   z# z = 
)r   propertyr-   r   appendjoinr?   
isfunction	getsourcer   r   _get_wrapped	TypeError	__class__OSError)	r+   onamesourcesattrnamefnr   oname_prefix_srcsrcs	            r0   r   r      s   & #x   )0 	 	Hh''B~'++27?RrwwlH'EFFGGG%b)) 
$R==D 5vd||444 NN)5xxxL    	99W%%%4
 3
	#C((CC 	 	 	'66Y'   ttt   	 	 	44	 
s<   D" "
E/-EE/EE/EE/"	E/.E/c                     t          j        |           p=t          j        |           p)t          | t                    pt          | t
                    S )zTrue if obj is a function ())r?   r   ismethodr   _builtin_func_type_builtin_meth_typer+   s    r0   is_simple_callabler   )  sQ    s## Ww'7'<'< Ws.//W3=cCU3V3VXr2   c                     t          j        dt          d           t          | d          rt	          |           s| j        } t          j        |           S )zWrapper around :func:`inspect.getfullargspec`

    In addition to functions and methods, this can also handle objects with a
    ``__call__`` attribute.

    DEPRECATED: Deprecated since 7.10. Do not use, will be removed.
    z]`getargspec` function is deprecated as of IPython 7.10and will be removed in future versions.rX   rY   __call__)r[   r\   r]   r   r   r   r?   getfullargspecr   s    r0   
getargspecr   .  sh     M <=O\]_ _ _ _ C$$ -?-D-D l!#&&&r2   c                     t          j        dt          d           t          j        | d         | d         | d         | d                   S )a  Format argspect, convenience wrapper around inspect's.

    This takes a dict instead of ordered arguments and calls
    inspect.format_argspec with the arguments in the necessary order.

    DEPRECATED (since 7.10): Do not use; will be removed in future versions.
    za`format_argspec` function is deprecated as of IPython 7.10and will be removed in future versions.rX   rY   argsvarargsvarkwdefaults)r[   r\   r]   r?   formatargspec)argspecs    r0   format_argspecr   @  sb     M <=O\]_ _ _ _  ')2D!(!17:3FH H Hr2   Tc                    t          j        dt          d           |                     d          }|d}nX	 |d         d         dk    }|r|d         d	d         |d<   n# t          t
          f$ r Y nw xY w| d
         t          |          z   }|                     d          }||                     d          }||                     dd          }||fS )z?DEPRECATED since 6.0. Extract call tip data from an oinfo dict.zZ`call_tip` function is deprecated as of IPython 6.0and will be removed in future versions.rX   rY   r   Nr   r   r.      rU   rR   rP   rL   r   )r[   r\   r]   r1   KeyError
IndexErrorr   )oinfoformat_callr   	call_linehas_selfdocs         r0   call_tipr   Q  s    M	2	    ii	""G		
	6vq)V3H  6")&/!"""5	 *% 	 	 	D	 &M."9"99	 ))$
%
%C
{ii())
{iiB''c>s   A   A43A4c                 v    | }d}t          | d          r$| j        } |dz  }|dk    r|S t          | d          $| S )aN  Get the original object if wrapped in one or more @decorators

    Some objects automatically construct similar objects on any unrecognised
    attribute access (e.g. unittest.mock.call). To protect against infinite loops,
    this will arbitrarily cut off after 100 levels of obj.__wrapped__
    attribute access. --TK, Jan 2016
    r   __wrapped__r   d   )r   r   )r+   orig_objis      r0   r   r   w  sY     H	A
sM
*
* o	Qs77O sM
*
*  Jr2   c                     t          |           } d}	 t          j        |           }nM# t          $ r5 	 t          j        | j                  }n# t
          t          f$ r Y nw xY wY nt
          $ r Y nw xY w|S )a^  Find the absolute path to the file where an object was defined.

    This is essentially a robust wrapper around `inspect.getabsfile`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    fname : str
        The absolute path to the file where the object was defined.
    N)r   r?   
getabsfiler   r   r   )r+   fnames     r0   rv   rv     s      s

CE"3''   	&s}55EE# 	 	 	D	     Ls8   ( 
A2AA2A!A2 A!!A2&	A21A2c                    t          |           } 	 t          j        |           d         }nV# t          $ r= 	 t          j        | j                  d         }n# t
          t          f$ r Y Y dS w xY wY nt
          $ r Y dS w xY w|S )aW  Find the line number in a file where an object was defined.

    This is essentially a robust wrapper around `inspect.getsourcelines`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    lineno : int
        The line number where the object definition starts.
    r   N)r   r?   getsourcelinesr   r   r   )r+   linenos     r0   find_source_linesr     s      s

C	',,Q/   	+CM::1=FF# 	 	 	444	 F    tt Ms8   , 
A?AA?A-(A?,A--A?2	A?>A?c                        e Zd Z ej        dd                              d          Zeej	        ddddf fd	Z
d(d	eedf         fd
Zd	efdZd Zd Zd(dZed)d            Zd(dZd(dZd*ded	efdZded	efdZdedededee         fdZd	efdZ	 	 	 	 	 d+dededee          de!deee         e"d         f         d	efd Z#	 	 	 	 	 	 d,dee          fd!Z$d-d"Z%d-d	e&fd#Z'e(d$             Z)g d%d%fd%d&d'Z* xZ+S ).r   TzLdictionary of mime to callable to add informations into help mimebundle dict)confighelp)r   Nr   c                     t          t          |                               ||           || _        t	          j        d| |          | _        | j        j        | _        || _        | 	                    |           d S )N)r*   r   r8   )outr*   style)
superr   __init__color_tabler   Parserparserformatstr_detail_levelset_active_scheme)r.   r   code_color_tableschemer   r*   r   r   s          r0   r   zInspector.__init__  sw     	i''vf'EEE& 'E$fMMMk( 0v&&&&&r2   r   rj   c                 p    t          |          sdS 	 t          t          |          |          S #  Y dS xY w)zReturn the call signature for any callable object.

        If any exception is generated, None is returned instead and the
        exception is suppressed.N)callable_render_signaturer   )r.   r+   r   s      r0   _getdefzInspector._getdef  sB    
 }} 	4	$Ys^^U;;;	44s   0 5c                 N    | j         j        j        || j         j        j        S )z*Return a header string with proper colors.)r   active_colorsheadernormal)r.   hs     r0   __headzInspector.__head  s0    +9@@+9@@B 	Br2   c                     |;| j                             |           | j        j                             |           d S d S rm   )r   r   r   )r.   r   s     r0   r   zInspector.set_active_scheme  sF    ..v666K#55f===== r2   c                 v    t          d|z  d           |rt          d|z             dS t                       dS )z-Generic message when no information is found.zNo %s found endzfor %sN)print)r.   msgr   s      r0   noinfozInspector.noinfo  sH    mc!s++++ 	(U"#####GGGGGr2   c                 F   t          |          st          d           dS d}t          j        |          r|                     d          }|                     ||          }||                     d|           dS t          ||                     |          d           dS )zwPrint the call signature for any callable object.

        If the object is a class, print the constructor information.zObject is not callable.Nr   zClass constructor information:
zdefinition headerr   r   )r   r   r?   rT   _Inspector__headr   r   r   )r.   r+   r   r   outputs        r0   pdefzInspector.pdef   s    
 }} 	+,,,F?3 	E[[!CDDF c%((>KK+E22222&V,,#666666r2   c                 @   | j         }g }t          |          }|r ||                              d|          }|r@|                     |d                     |                    t	          |                     t          j        |          rgt          |d          rWt          |j                  }|@|                     |d                     |                    t	          |                     nft          |d          rVt          |j	                  }|r@|                     |d                     |                    t	          |                     |s| 
                    d|           dS t          j        d	                    |                     dS )
a  Print the docstring for any object.

        Optional:
        -formatter: a function to run the docstring through for specially
        formatted docstrings.

        Examples
        --------
        In [1]: class NoInit:
           ...:     pass

        In [2]: class NoDoc:
           ...:     def __init__(self):
           ...:         pass

        In [3]: %pdoc NoDoc
        No documentation found for NoDoc

        In [4]: %pdoc NoInit
        No documentation found for NoInit

        In [5]: obj = NoInit()

        In [6]: %pdoc obj
        No documentation found for obj

        In [5]: obj2 = NoDoc()

        In [6]: %pdoc obj2
        No documentation found for obj2
        z
plain/textzClass docstring:r   NzInit docstring:r   zCall docstring:documentationr   )r   r@   r1   r   r   r?   rT   hasattrr   r   r   r   r   )	r.   r+   r   	formatterheadlinesr   init_dscall_dss	            r0   pdoczInspector.pdoc  s   D {C[[ 	52""<44B 	%LL011222LL$$$?3 		.GC$<$< 		.S\**G"TT"344555VG__---S$$ 	.S\**G .TT"344555VG__--- 	(KK.....Idii&&'''''r2   c                     t          j                     	 t          ||          }n# t          $ r d}Y nw xY w||                     d|           dS t          j        |                     |                     dS )z$Print the source code for an object.)r   NrM   )	linecache
checkcacher   r   r   r   r   )r.   r+   r   r   s       r0   psourcezInspector.psourceP  s     		Cu---CC 	 	 	CCC	 ;KK%(((((Idkk#&&'''''s   ' 66c                    t          |          }||                     d|           dS t          |          }|t          d           dS |                    d          rt          d|z             dS t
          j                            |          st          d|z             dS t          j        | 	                    t          j        |d                    |d	z
             dS )
z0Show the whole file where an object was defined.NrJ   zCould not find file for objectrt   z File %r is binary, not printing.z%File %r does not exist, not printing.F)skip_encoding_cookier   )r   r   rv   r   rw   rx   ry   rz   r   r   r   read_py_file)r.   r+   r   r   r   s        r0   pfilezInspector.pfile_  s     #3''>KK&&&F# =233333^^344 	g4u<=====&& 	g9EABBBBB
 Idkk&"5eRW"X"X"XYY[ade[efffffr2   textc                     |dt          j        |           dd}||S  ||          }t          |t                    s	|d| ddS t          |fi |S )aR  Return a mime bundle representation of the input text.

        - if `formatter` is None, the returned mime bundle has
           a ``text/plain`` field, with the input text.
           a ``text/html`` field with a ``<pre>`` tag containing the input text.

        - if ``formatter`` is not None, it must be a callable transforming the
          input text into a mime bundle. Default values for ``text/plain`` and
          ``text/html`` representations are the ones described above.

        Note:

        Formatters returning strings are supported but this behavior is deprecated.

        z<pre>z</pre>
text/plain	text/html)htmlescaper   dict)r.   r   r   r   	formatteds        r0   _mime_formatzInspector._mime_formatx  s    " :T!2!2:::
 

 O!	$Ii.. 3 '0>Wi>W>W>WXXX H22	222r2   bundlec                 D   t          |d         t                    sJ |d         D ]}t          |t                    sJ i }g }t          d |d         D                       }|d         D ]h\  }}|                    d          }d|v rdnd}|                    |                     |dz              |t          |          z
  dz   | |            id                    |          |d<   d|v rt          |d         t                    sJ |d         D ]}t          |t                    sJ t          |d         t          t          f          r(d                    d |d         D                       |d<   |	                                D ]}	|	dv r||	         ||	<   |S )	zRFormat a mimebundle being created by _make_info_unformatted into a real mimebundler  c              3   :   K   | ]\  }}t          |          V  d S rm   len)rA   r   _s      r0   	<genexpr>z(Inspector.format_mime.<locals>.<genexpr>  s,      ;;da3q66;;;;;;r2   r   r   :r  c              3   ,   K   | ]\  }}d | d| V  dS )z<h1>z</h1>
Nr9   )rA   r   bodys      r0   r  z(Inspector.format_mime.<locals>.<genexpr>  s7      XXLT4/D////XXXXXXr2   )r  r  )
r   ri   tuplemaxstripr   r   r  r   keys)
r.   r	  itemnew_br   _lenr   r  delimrn   s
             r0   format_mimezInspector.format_mime  s    &.55555<( 	+ 	+DdE******;;f\&:;;;;; . 	 	JD$::d##D DLLDDcELL;;tCx((O4#d))+;S*@O%OOO    #ii..l&  f[1488888{+ / /!$......&-e}== %)YYXXF;DWXXX& &k"  	% 	%A///!!9ar2   titlekeyrf   c                     ||v s||v rdS ||         }|^|                      ||          }|d                             ||d         f           |d                             ||d         f           dS dS )z^Append an info value to the unformatted mimebundle being constructed by _make_info_unformattedNr  r  )r  r   )	r.   r	  r  r  rc   rf   r   r/   formatted_fields	            r0   _append_info_fieldzInspector._append_info_field  s     M!!SM%9%9FS	"//yAAO< ''0M(NOOO;&&{/K'LMMMMM r2   c                     g g d}	 d+dt           dt          dt          f fd}dt          f fd}d	         r ||d
d           nd         r2|dk    r ||dd|           n ||dd|            ||dd           nRd         st          |          r} ||dd|            ||dd|            ||dd|           |dk    rd         r ||dd|           n ||dd|            ||dd            ||dd            ||dd           n ||dd|            ||dd |            ||dd            ||d!d           d"         d#k    r ||d$d"            ||d%d&            ||dd           |dk    rd         r ||dd|           n ||dd|            ||d'd(|            ||dd|            ||d)d*|           |S ),z;Assemble the mimebundle as unformatted lists of informationr  Nr	  r  r  c                 >                         | |||           d S )N)r  r  rc   rf   r   )r   )r	  r  r  r   rc   rf   r.   s       r0   append_fieldz6Inspector._make_info_unformatted.<locals>.append_field  s>     ##+# $     r2   rj   c                 N                         |           t          |           dS )Nr  )r   r=   )r   r.   s    r0   code_formatterz8Inspector._make_info_unformatted.<locals>.code_formatter  s*    "kk$//$T]]  r2   r'   ReprrH   r&   r   SourcerM   	DocstringrL   FilerJ   rT   	SignaturerK   zInit signaturerN   zInit docstringrP   TyperF   
SubclassesrS   zCall signaturerQ   zString formr)   Interactive	NamespaceLengthrI   zClass docstringrO   zCall docstringrR   rm   )r"   r8   r#   r   )	r.   r+   rc   r   re   rf   r	  r#  r%  s	   ` `  `   r0   _make_info_unformattedz Inspector._make_info_unformatted  s+   
 %
 %
 HL
	 
	%
	.1
	8;
	 
	 
	 
	 
	 
	 
	 
		F 	 	 	 	 	 	 	? /	PL7777)_ ,	PaVXxHHHHV[+yIIIL0000)_ %	P 23 7 7 %	PLlNKKKL!13DnUUULk9EEEaDNVXxHHHHV%57GSSSL000L555L|<<<< LlNKKKL!1:~NNNL555L>>> K M11V[+>>>L8444L000 aDNVXxHHHHV[+yIIIL!24EyQQQL!13CYOOOL!13CYOOOr2   r9   r+   r   rc   re   c                 *   |                      ||||          }t          |          }|                     |||||          }| j        rt	          |||||          }	| j                                        D ]\  }
}d t          j        |          j        	                                D             }t          |          dk    r ||	          }n(t          j        dt          d            |||          }||||
<   |                     |          S )	a4  Retrieve an info dict and format it.

        Parameters
        ----------
        obj : any
            Object to inspect and return info from
        oname : str (default: ''):
            Name of the variable pointing to `obj`.
        formatter : callable
        info
            already computed information
        detail_level : integer
            Granularity of detail level, if set to 1, give more information.
        omit_sections : list[str]
            Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
        r   rc   re   )re   rf   )r+   rc   rd   re   rf   c                 F    g | ]}|j         t          j        j         k    |S r9   )defaultr?   	Parameter)rA   	parameters     r0   
<listcomp>z'Inspector._get_info.<locals>.<listcomp>N  s6     ' ' '! (G,=,EEE EEEr2   r   zMIME hook format changed in IPython 8.22; hooks should now accept a single parameter (InspectorHookData); support for hooks requiring two-parameters (obj and info) will be removed in a future versionrX   rY   )rc   ri   r0  
mime_hooksrb   itemsr?   r   
parametersvaluesr  r[   r\   r]   r  )r.   r+   r   r   rc   re   rf   rd   r	  	hook_datar  hookrequired_parametersress                 r0   	_get_infozInspector._get_info!  s^   4 IIcTIUU	]++,,%' - 
 
 ? 	&)#)+  I "_2244 & &	T' '%,%6t%<%<%G%N%N%P%P' ' '#
 *++q00$y//CCM] +#$    $sD//C?"%F3K'''r2   c                 v    |J |                      ||||||          }|s|d= t          j        |           dS )a   Show detailed information about an object.

        Optional arguments:

        - oname: name of the variable pointing to the object.

        - formatter: callable (optional)
              A special formatter for docstrings.

              The formatter is a callable that takes a string as an input
              and returns either a formatted string or a mime type bundle
              in the form of a dictionary.

              Although the support of custom formatter returning a string
              instead of a mime type bundle is deprecated.

        - info: a structure with some information fields which may have been
          precomputed already.

        - detail_level: if set to 1, more information is given.

        - omit_sections: set of section keys and titles to omit
        N)rf   r  )r@  r   )	r.   r+   r   r   rc   re   enable_html_pagerrf   info_bs	            r0   pinfozInspector.pinfob  s^    B 	4] ( 
 
 ! 	${#	&r2   c                 l    t          j        dt          d           |                     ||||          S )z
        Inspector.info() was likely improperly marked as deprecated
        while only a parameter was deprecated. We "un-deprecate" it.
        zThe `Inspector.info()` method has been un-deprecated as of 8.0 and the `formatter=` keyword removed. `Inspector._info` is now an alias, and you can just call `.info()` directly.rX   rY   r2  )r[   r\   r]   rc   )r.   r+   r   rc   re   s        r0   _infozInspector._info  sG     	B 	
 	
 	
 	
 yyE<yPPPr2   c           
      v   |d}d}d}n|j         }|j        }|j        }|                    d          d         }d}	d}
|rQ|j        Jt          |j        t                    r0t          |j        t                    }|                    |d          }	t          t          i d t          D             |d||dd          }|	r|	}nt|r\t          |          s&	 d	|d
         z  }nV#  dt          |          z   }Y n@xY wdt          |          z   }|j        r|d|j        z   z  }nt          |          }|d}n|}|
|z   }d}t!          |dz
  dz            }|rd|d<   n|rd|d<   nt#          |          j        |d<   	 |j        }t          |          |d<   n#  Y nxY w|| j        k    r	 t          |          }|st+          |          |k    rp|d|         dz   || d         z   }ddt+          d                                          z  z                       d |                    d          D                       }||d<   n#  Y nxY w|r||d<   	 t          t+          |                    |d<   n# t0          $ r Y nw xY wd}t3          |          }|d}nA|                    d          rd}n|                    d          rd}t7          |          |d <   |rgt9          j                     	 t=          |t>                    s|s+tA          ||          }||!                                }||d!<   n# t0          $ r Y nw xY w|r.| "                    |                    d!          |          s||d"<   tG          j$        |          rd|d#<   	 | %                    ||          }n# tL          $ r d}Y nw xY w	 |j'        }|(	 | %                    ||          }n# tL          $ r Y nw xY wt          |          }|tP          k    rd}n# tL          $ r d}Y nw xY w|r||d$<   |r||d%<   d& t"          )                    |          D             }t+          |          d'k     rd(                    |          }n!d(                    |dd'         d)gz             }||d*<   n| %                    ||          }|r||d+<   |rB	 t          |d,          }t          |          }n	#  d}Y nxY w|tT          v rd}|r||k    r||d-<   	 t          |j'                  }|tP          k    rd}n# tL          $ r d}Y nw xY w|r||d%<   tW          |d.          rrtY          |          sc| %                    |j-        |          }|r||                    d+          k    r||d/<   t          |j-                  }|t\          k    rd}|r||d0<   |S )1as  Compute a dict with detailed information about an object.

        Parameters
        ----------
        obj : any
            An object to find information about
        oname : str (default: '')
            Name of the variable pointing to `obj`.
        info : (default: None)
            A struct (dict like with attr access) with some information fields
            which may have been precomputed already.
        detail_level : int (default:0)
            If set to 1, more information is given.

        Returns
        -------
        An object info dict with known fields from `info_fields` (see `InfoDict`).
        NFr   .c                     i | ]}|d S rm   r9   )rA   r/   s     r0   rp   z"Inspector.info.<locals>.<dictcomp>  s    99955$999r2   T)rU   r(   r'   r&   rS   z!Alias to the system command:
  %sr   zAlias: z	Alias to z
Docstring:
z<no docstring>      rX   zMagic functionrF   zSystem aliasrG   z <...> r   r   rH   c              3   >   K   | ]}|                                 V  d S rm   )r  )rA   qs     r0   r  z!Inspector.info.<locals>.<genexpr>  sC       O O&'		O O O O O Or2   r)   rI   rt   z<string>z9Dynamically generated function. No source code available.rJ   rM   rL   rT   rN   rP   c                     g | ]	}|j         
S r9   )r3   )rA   subs     r0   r7  z"Inspector.info.<locals>.<listcomp>N  s    FFFcS\FFFr2   
   , z...rS   rK   r   rO   r   rQ   rR   )/r&   r'   r)   splitr*   r   	HOOK_NAMEr-   r1   r   rE   r^   r   r8   rg   r@   rh   typer3   r   r   r  
expandtabsr   r   rv   rw   r   r   r   r   r   r   rstrip_source_contains_docstringr?   rT   r   r_   r   _object_init_docstring__subclasses___builtin_type_docstringsr   r   r   _func_call_docstring) r.   r+   r   rc   re   r&   r'   ospaceatt_nameparents_docspreludeparents_docs_dictr   r   
ds_or_None
string_maxshalfbclassostrbinary_filer   r   init_defobj_initr   names	all_namesdeflnclsclass_dsrQ   r   s                                    r0   rc   zInspector.info  st   ( <GGFFlGlG^F ;;s##B' 	ADK+Y0O0O+ 'Y ? ?,004@@L	99L999	 "!&&"& 	
 
  	 BB 	 C== 9.=AFBB."SXX-BBB 3s88+; 9*S[88BJ!%r\ 
Z!^q()) 	2/C 	2-C#Cyy1C	]F #FC	D 40003xx# D		J(>(><)3dE677mCD !3]-E-E-G-G)H)H#HHNN O O+/::d+;+;O O O  D &*M"" 	&%C	CMMCMM 	 	 	D	 #= KK~~566 T"
++ TS'..CK  	  """c8,, (K (#C//C!jjll$'CM     	"d55cggh6G6GLL 	"!C ?3 V	4!C	N <<U33!       #< ##'<<%#@#@)    **444"G "     2)1%& 0(/$%FFT-@-@-E-EFFFE5zzB IIe,,		 IIeCRCj%&899	 )C LLe,,E *$)L!  6+!#k22C  &c{{HH$#HHH 777#H 6h-5C)* ..444"G!    0(/$% C,, 45G5L5L 4<<e<< /SWW\-B-B!B!B '/C
O ..222"G 4,3C()
s   C" "C8<F F)BI II2 2
I?>I?/AL2 2
L?>L?N$ $N32N37P O 
O%$O%PP:S S <!T T-,T-c                     	 t          j        t          |                     j        \  }t          j        |          |k    S # t
          $ r Y dS w xY w)z
        Check whether the source *src* contains the docstring *doc*.

        This is is helper function to skip displaying the docstring if the
        source already contains it, avoiding repetition of information.
        F)astparser   r  get_docstringr   )r   r   def_nodes      r0   rX  z$Inspector._source_contains_docstring  s[    	)F3KK005KX$X..#55 	 	 	 55		s   ?A 
AAF)
list_typesc                   d}d}|r;t          j         d                    t          t                                         dS |                                }	t          |	          }
|
dk    r	|	d         }n|
dk    r|	\  }}nt          d|z            |D ]-}||vr't          d	|d
|                                          .t                      t                      }}|D ]g}||         }t          |          |v r|
                    t          |                     t          |||||          }|                    |           ht          j         d                    t          |                               dS )a  Search namespaces with wildcards for objects.

        Arguments:

        - pattern: string containing shell-like wildcards to use in namespace
          searches and optionally a type specification to narrow the search to
          objects of that type.

        - ns_table: dict of name->namespaces for search.

        Optional arguments:

          - ns_search: list of namespace names to include in search.

          - ignore_case(False): make the search case-insensitive.

          - show_all(False): show all names, including those starting with
            underscores.

          - list_types(False): list all available object types for object matching.
        allr   r   Nr   r   rX   z)invalid argument string for psearch: <%s>zinvalid namespace <z>. Valid names: )ignore_caseshow_all)r   r   sortedr   rS  r  
ValueErrorr  setidaddr   update)r.   patternns_table	ns_searchrw  rx  rt  type_patternfiltercmdslen_cmdsrU   search_resultnamespaces_seenns_namenstmp_ress                    r0   psearchzInspector.psearch  s   4   	Idii| 4 455666F}}YYq==!WFF]]"&F<<H$% & & &  	9 	9D8## j"&$$x}}"8 9 9 9 $
 *-  	* 	*G'"B"vv((2'''$Rv0;hP P PG  ))))	$))F=112233333r2   r   )r   Nrm   )r   NNr   r9   )r   NNr   Tr9   )r   Nr   ),r3   r4   r5   	traitletsr   tagr8  r   r   ANSICodeColorsr   r   r8   r   r   r   r   r   r   r   r   r   r  r  r"   r#   r  r   r   r0  r	   r
   r%   rh   r   r@  rD  rF  rE   rc   staticmethodrX  r  __classcell__)r   s   @r0   r   r     sG       [   
cc  "#2' ' ' ' ' ' 
 
eCHo 
 
 
 
B# B B B B
> > >
  7 7 7 7, 7( 7( 7( \7(r( ( ( (g g g g2 3  3  3  3  3  3  3D$"3 $ $ $ $ $LN!N N 	N CyN N N N$L	L L L Ld  $57?( ?(?( ?(
 uo?( ?( T#Yb	12?( 
?( ?( ?( ?(H  $' '
 uo' ' ' 'RQ Q Q Qk k k k k kZ   \  13!5@4@E@4 @4 @4 @4 @4 @4 @4 @4 @4r2   c                 d   g }d}d}| j                                         D ]}|j        t          j        j        k    rd}n|r|                    d           d}|j        t          j        j        k    rd}n3|j        t          j        j        k    r|r|                    d           d}|                    t          |                     |r|                    d           t          |          t          d |D                       z   dk    r4d                    |d                    d	 |D                                 }n)d
                    |d                    |                    }| j        t          j        ur1t          j        | j                  }|d                    |          z  }|S )z
    This was mostly taken from inspect.Signature.__str__.
    Look there for the comments.
    The only change is to add linebreaks when this gets too long.
    FT/*c              3   :   K   | ]}t          |          d z   V  dS )rX   Nr  rA   rs     r0   r  z$_render_signature.<locals>.<genexpr>  s,      66!3q66A:666666r2   K   z{}(
{})r   c              3   @   K   | ]}d                      |          V  dS )z    {},
N)r   r  s     r0   r  z$_render_signature.<locals>.<genexpr>  sA       73 73&'Kq!!73 73 73 73 73 73r2   z{}({})rR  z -> {})r:  r;  kindr?   r5  POSITIONAL_ONLYr   VAR_POSITIONALKEYWORD_ONLYr8   r  sumr   r   return_annotation_emptyformatannotation)obj_signatureobj_nameresultpos_onlykw_onlyparamrenderedannos           r0   r   r     s    FHG)0022 " ":*:::HH 	MM#H:*999GGZ7,999g9MM#Gc%jj!!!! c 8}}s66v666666;;$$Xrww 73 73+173 73 73 03 03 
 
 ??8TYYv->->??&gn<<'(GHHHOOD)))Or2   r  )T)frg   __all__dataclassesr   r?   r   textwrapr   rp  r  ior{   r   rx   typesr[   typingr   r	   r
   r   r   r   r   r   r   r  IPython.corer   IPython.lib.prettyr   IPython.testing.skipdoctestr   IPython.utilsr   r   IPython.utils.dir2r   IPython.utils.pathr   IPython.utils.textr   IPython.utils.wildcardr   r   IPython.utils.coloransir   IPython.utils.colorabler   IPython.utils.decoratorsr   pygmentsr   pygments.lexersr   pygments.formattersr    rT  r8   r"   r7   r#   r%   r=   FunctionTyper   r\  objectr   rY  
ModuleType
MethodTyper   r[  rU  rv  r   upperr   Colorsr  r   rE   ri   r  r^   r`   rb   r6   rr   r   r@   r   r   r   r   r   r   rv   r   r   r   r9   r2   r0   <module>r     s     
' " ! ! ! ! !             



           				  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
           % % % % % % 4 4 4 4 4 4 , , , , , , , , + + + + + + , , , , , , % % % % % % ? ? ? ? ? ? ? ? . . . . . . - - - - - - * * * * * *       ' ' ' ' ' ' - - - - - -'	  $CeCHo)>$>? 9 ? ? ?cN	 " " " $ $ $ $ $ $ $ $2I I I )2: 0   % 0%2B % 2H >   
 T#YY T#)__  
)    y   2 tH,113344	K 	K 	K         
      
    	 
            *  05d#    *< <c$h < < < <~X X X
 ' ' '" H H H  " " " "J  $ hsm        F  >M4 M4 M4 M4 M4	 M4 M4 M4`(# ( ( ( ( ( (r2   