o
    Ďi                     @   s  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 dZ>dd Z?ej@jAj ZBeCjDj ZEdd ejFejGej@eHfD ZIeJeKZLeJe:jMZNe.ZOe"jPZQG d d! d!eZReSeRj<T ZUd"d# ZVeG d$d% d%ZWe2d&d&d&d'd(e:d)eXd*eXd+eXd,eXd-eRfd.d/ZYd0d1 ZZd-ee:df fd2d3Z[dId-ee:df fd5d6Z\d7d8 Z]e2d9d: Z^e2d;d< Z_e2dJd>d?Z`d@dA Zad-ee: fdBdCZbdDdE ZcG dFd de0Zdd-e:fdGdHZedS )KzTools 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                   @   sJ   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d Zd	S )
OInfoismagicisaliasfound	namespaceparentobjc                 C   s
   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field r-   Q/home/jeff/fluffinator/venv/lib/python3.10/site-packages/IPython/core/oinspect.pygetK   s   
z	OInfo.getN)	__name__
__module____qualname__bool__annotations__r	   strr   r/   r-   r-   r-   r.   r#   B   s   
 r#   c                 C   s   t | t tddS )NT)	noclasses)r   r   r   )coder-   r-   r.   pylight\   s   r8   c                 C   s   h | ]}t |qS r-   )inspectgetdoc).0tr-   r-   r.   	<setcomp>b   s    
r=   c                   @   s   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)r0   r1   r2   r	   r5   r4   r3   r-   r-   r-   r.   r>   t   s*   
 r>   c                 C   s0   | dkrt jdtd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AttributeErrorr0   )rN   r-   r-   r.   __getattr__   s   rX   c                   @   sB   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)r0   r1   r2   __doc__r   r4   r	   r#   r>   intlistr5   r-   r-   r-   r.   rY      s   
 rY   F)rM   r%   r$   rN   r&   rM   r%   r$   returnc                    sL   |  fddt D  |  d< | d< | d< | d< | d< td	i  S )
z1Make an object info dict with all fields present.c                    s   i | ]	}| vr|d qS Nr-   )r;   kinfodictr-   r.   
<dictcomp>   s    zobject_info.<locals>.<dictcomp>rN   r&   rM   r%   r$   Nr-   )rV   r>   )rN   r&   rM   r%   r$   kwr-   rd   r.   object_info   s   rh   c                 C   st   t | }|du r
dS |drdS tj|sdS t|d}t|j	\}}W d   |S 1 s3w   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_linesr-   r-   r.   get_encoding   s   

rx   c                 C   sB   z|   }W n	 ty   Y nw t|trt|S t | }|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:   	Exception
isinstancer5   r9   cleandoc)r)   dsdocstrr-   r-   r.   r:      s   



r:    c           	      C   s  t | trTg }dD ]A}t| |}|durJt|}|rd| nd}|dd||f t|r>t|}|r=|t	| q	|d||t
|f  q	|rRd|S dS t| } zt| }W |S  ty   z
t| j}W Y |S  ttfy~   Y Y dS w  ty   Y dS w )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
%s%s = %s

)rz   propertyr*   rx   appendjoinr9   
isfunction	getsourcer   r   _get_wrapped	TypeError	__class__OSError)	r)   onamesourcesattrnamefnrv   oname_prefix_srcsrcr-   r-   r.   r      sD   



r   c                 C   s(   t | pt | pt| tpt| tS )zTrue if obj is a function ())r9   r   ismethodrz   _builtin_func_type_builtin_meth_typer)   r-   r-   r.   is_simple_callable)  s
   r   c                 C   s2   t jdtdd t| drt| s| j} t| 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.rP   rQ   __call__)rS   rT   rU   r   r   r   r9   getfullargspecr   r-   r-   r.   
getargspec.  s   

r   c                 C   s0   t jdtdd t| 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.rP   rQ   argsvarargsvarkwdefaults)rS   rT   rU   r9   formatargspec)argspecr-   r-   r.   format_argspec@  s   
r   Tc              	   C   s   t jdtdd | d}|du rd}n*z
|d d dk}W n ttfy)   Y nw |r6|d d	d |d< | d
 t| }| d}|du rL| d}|du rV| 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.rP   rQ   r   Nr   r   r+      rN   rK   rI   rE   r~   )rS   rT   rU   r/   KeyError
IndexErrorr   )oinfoformat_callr   	call_linehas_selfdocr-   r-   r.   call_tipQ  s,   


r   c                 C   s:   | }d}t | dr| j} |d7 }|dkr|S t | ds	| 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ir-   r-   r.   r   w  s   

r   c                 C   sn   t | } d}zt| }W |S  ty-   z
t| j}W Y |S  ttfy,   Y Y |S w  ty6   Y |S w )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   r9   
getabsfiler   r   r   )r)   fnamer-   r-   r.   rk     s"   rk   c                 C   sr   t | } z
t| d }W |S  ty/   zt| jd }W Y |S  ttfy.   Y Y dS w  ty8   Y dS w )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   r9   getsourcelinesr   r   r   )r)   linenor-   r-   r.   find_source_lines  s   
r   c                       s  e Zd ZejdddjddZeej	ddddf fdd	Z
d;d
eedf fddZd
efddZdd Zdd Zd;ddZed<ddZd;ddZd;ddZd=ded
efddZded
efdd Zded!ed"ed#ee fd$d%Zd
efd&d'Z						(d>d)ed*ed+ee  d,e!d#eee e"d( f d
efd-d.Z#							(d?d+ee  fd/d0Z$d@d1d2Z%d@d
e&fd3d4Z'e(d5d6 Z)g d7d7fd7d8d9d:Z*  Z+S )Ar   TzKdictionary of mime to callable to add information into help mimebundle dict)confighelp)r   Nr   c                    sJ   t t| j||d || _tjd| |d| _| jj| _|| _| 	| d S )N)r(   r   r5   )outr(   style)
superr   __init__color_tabler   Parserparserformatstr_detail_levelset_active_scheme)r+   r   code_color_tableschemer   r(   r   r   r-   r.   r     s   	
zInspector.__init__r~   ra   c                 C   s*   t |sdS ztt||W S    Y dS )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   r-   r-   r.   _getdef  s   zInspector._getdefc                 C   s   d| j jj|| j jjf S )z*Return a header string with proper colors.z%s%s%s)r   active_colorsheadernormal)r+   hr-   r-   r.   __head  s   zInspector.__headc                 C   s*   |d ur| j | | jj | d S d S rb   )r   r   r   )r+   r   r-   r-   r.   r     s   zInspector.set_active_schemec                 C   s.   t d| dd |rt d|  dS t   dS )z-Generic message when no information is found.zNo %s found endzfor %sN)print)r+   msgr   r-   r-   r.   noinfo  s   
zInspector.noinfoc                 C   sh   t |s
td dS d}t|r| d}| ||}|du r(| d| dS t|| |d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   r9   rM   _Inspector__headr   r   r   )r+   r)   r   r   outputr-   r-   r.   pdef   s   

zInspector.pdefc           	      C   s   | j }g }t|}|r||d|}|r#||d |t| t|rEt|drEt|j}|durD||d |t| nt|dr_t|j	}|r_||d |t| |si| 
d| dS t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:   r/   r   r   r9   rM   hasattrr   r   r   r   r   )	r+   r)   r   	formatterheadlinesr|   init_dscall_dsr-   r-   r.   pdoc  s,   "


zInspector.pdocc                 C   s\   t   zt||d}W n ty   d}Y nw |du r$| d| dS t| | dS )z$Print the source code for an object.)r   NrF   )	linecache
checkcacher   ry   r   r   r   )r+   r)   r   r   r-   r-   r.   psourceP  s   zInspector.psourcec                 C   s   t |}|du r| d| dS t|}|du rtd dS |dr+td|  dS tj|s9td|  dS t| 	t
j|dd|d	  dS )
z0Show the whole file where an object was defined.NrC   zCould not find file for objectri   z File %r is binary, not printing.z%File %r does not exist, not printing.F)skip_encoding_cookier   )r   r   rk   r   rl   rm   rn   ro   r   r   r   read_py_file)r+   r)   r   r   rt   r-   r-   r.   pfile_  s   
$zInspector.pfiletextc                 C   sX   |dt | dd}|du r|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/htmlN)htmlescaperz   dict)r+   r   r   r   	formattedr-   r-   r.   _mime_formatx  s   
zInspector._mime_formatbundlec           
      C   sB  t |d ts	J |d D ]	}t |tsJ qi }g }tdd |d D }|d D ])\}}|d}d|v r9dnd}|| |d  |t| d  | |  q*d||d< d|v rt |d tshJ |d D ]	}t |tsuJ qlt |d ttfrddd |d D |d< |	 D ]}	|	d	v rq||	 ||	< q|S )
zRFormat a mimebundle being created by _make_info_unformatted into a real mimebundler   c                 s   s    | ]	\}}t |V  qd S rb   len)r;   r   _r-   r-   r.   	<genexpr>      z(Inspector.format_mime.<locals>.<genexpr>r   r   :r   c                 s   s$    | ]\}}d | d| V  qdS )z<h1>z</h1>
Nr-   )r;   r   bodyr-   r-   r.   r     s   " )r   r   )
rz   r`   tuplemaxstripr   r   r   r   keys)
r+   r   itemnew_br   _lenr   r   delimrc   r-   r-   r.   format_mime  s4   
(zInspector.format_mimetitlekeyr]   c           	      C   sd   ||v s||v r
dS || }|dur0|  ||}|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   rZ   r]   r   r,   formatted_fieldr-   r-   r.   _append_info_field  s   
zInspector._append_info_fieldc           	         s  g g d}	d-dt dtdtf fdd}dtffd	d
} d r+||dd |S  d rJ|dkr;||dd| n||dd| ||dd |S  d sRt|r||dd| ||dd| ||dd| |dkrw d rw||dd| n||dd| ||dd ||dd ||dd  |S ||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                    s   j | || |d d S )N)r   r   rZ   r]   r   )r   )r   r   r   r   rZ   r]   r+   r-   r.   append_field  s   
z6Inspector._make_info_unformatted.<locals>.append_fieldra   c                    s     | t| dS )Nr   )r   r8   )r   )r+   r-   r.   code_formatter  s   z8Inspector._make_info_unformatted.<locals>.code_formatterr%   ReprrA   r$   r   SourcerF   	DocstringrE   FilerC   rM   	SignaturerD   zInit signaturerG   zInit docstringrI   Typer?   
SubclassesrL   zCall signaturerJ   zString formr'   Interactive	NamespaceLengthrB   zClass docstringrH   zCall docstringrK   rb   )r!   r5   r"   r   )	r+   r)   rZ   r   r\   r]   r   r  r  r-   r   r.   _make_info_unformatted  s^   /(z Inspector._make_info_unformattedr-   r)   r   rZ   r\   c                 C   s   | j ||||d}t|}| j|||||d}| jrZt|||||d}	| j D ]1\}
}dd t|j	 D }t
|dkrD||	}ntjdtdd	 |||}|d
urY|||
< q(| |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   rZ   r\   )r\   r]   )r)   rZ   r[   r\   r]   c                 S   s   g | ]}|j tjj kr|qS r-   )defaultr9   	Parameter)r;   	parameterr-   r-   r.   
<listcomp>N  s
    z'Inspector._get_info.<locals>.<listcomp>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 versionrP   rQ   N)rZ   r`   r  
mime_hooksrY   itemsr9   r   
parametersvaluesr   rS   rT   rU   r   )r+   r)   r   r   rZ   r\   r]   r[   r   	hook_datar   hookrequired_parametersresr-   r-   r.   	_get_info!  sB   


zInspector._get_infoc           	      C   s:   |dusJ | j ||||||d}|s|d= t| 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)r]   r   )r  r   )	r+   r)   r   r   rZ   r\   enable_html_pagerr]   info_br-   r-   r.   pinfob  s   !zInspector.pinfoc                 C   s"   t jdtdd | j||||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.rP   rQ   r  )rS   rT   rU   rZ   )r+   r)   r   rZ   r\   r-   r-   r.   _info  s   zInspector._infoc               	   C   s,  |du rd}d}d}n	|j }|j}|j}|dd }d}	d}
|r8|jdur8t|jtr8t|jt}||d}	t	t
i dd tD |d||dd	}|	rQ|	}n8|r|t|skzd
|d  }W n)   dt| }Y ndt| }|jr{|d|j 7 }nt|}|du rd}n|}|
| }d}t|d d }|rd|d< n|rd|d< nt|j|d< z|j}t||d< W n   Y || jkrz6t|}|st||kr|d| d || d  }ddtd   dd |dD }||d< W n   Y |r||d< z
tt||d< W n
 ty   Y nw d}t|}|du r&d}n|dr/d}n|d r7d!}t||d"< |rlt  zt|tsN|s`t ||}|dur\|! }||d#< W n
 tyk   Y nw |r}| "|d#|s}||d$< t#$|rd|d%< z| %||}W n t&y   d}Y nw z|j'}W n t&y   d}Y n$w |du rz| %||}W n
 t&y   Y nw t|}|t(krd}|r||d&< |r||d'< d(d) t)|D }t|d*k rd+|}nd+|dd* d,g }||d-< |S | %||}|r||d.< |r>zt|d/}W n   d}Y nt|}|t*v r2d}|r>||kr>||d0< zt|j'}|t(krKd}W n t&yX   d}Y nw |r`||d'< t+|d1rt,|s| %|j-|}|r||d.kr||d2< t|j-}|t.krd}|r||d3< |S )4as  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                 S   s   i | ]}|d qS rb   r-   )r;   r,   r-   r-   r.   rf         z"Inspector.info.<locals>.<dictcomp>T)rN   r&   r%   r$   rL   z!Alias to the system command:
  %sr   zAlias: z	Alias to z
Docstring:
z<no docstring>      rP   zMagic functionr?   zSystem aliasr@   z <...> r   r   rA   c                 s   s    | ]}|  V  qd S rb   )r   )r;   qr-   r-   r.   r     s    
z!Inspector.info.<locals>.<genexpr>r'   rB   ri   z<string>z9Dynamically generated function. No source code available.rC   rF   rE   rM   rG   rI   c                 S   s   g | ]}|j qS r-   )r0   )r;   subr-   r-   r.   r  N  r"  z"Inspector.info.<locals>.<listcomp>
   , z...rL   rD   r   rH   r   rJ   rK   )/r$   r%   r'   splitr(   r   	HOOK_NAMEr*   r/   r   r>   rV   r   r5   r^   r:   r_   typer0   r   r   r   
expandtabsr   ry   rk   rl   r   r   r   rz   r   r   rstrip_source_contains_docstringr9   rM   r   rW   r   _object_init_docstring__subclasses___builtin_type_docstringsr   r   r   _func_call_docstring) r+   r)   r   rZ   r\   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_dsrJ   r   r-   r-   r.   rZ     s@  








2




zInspector.infoc                 C   s8   zt t| j\}t ||kW S  ty   Y dS 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_docstringry   )r   r   def_noder-   r-   r.   r.    s   z$Inspector._source_contains_docstringF)
list_typesc                C   s   d}d}|rt  dtt dS | }	t|	}
|
dkr#|	d }n|
dkr,|	\}}ntd| |D ]}||vrDtd	|| f q4t t }}|D ]"}|| }t	||v r[qN|
t	| t|||||d
}|| qNt  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   rP   z)invalid argument string for psearch: <%s>z'invalid namespace <%s>. Valid names: %s)ignore_caseshow_all)r   r   sortedr   r)  r   
ValueErrorr   setidaddr   update)r+   patternns_table	ns_searchrK  rL  rI  type_patternfiltercmdslen_cmdsrN   search_resultnamespaces_seenns_namenstmp_resr-   r-   r.   psearch  s>   


zInspector.psearchr~   )r~   Nrb   )r~   NNr   r-   )r~   NNr   Tr-   )r~   Nr   ),r0   r1   r2   	traitletsr
   tagr  r   r   ANSICodeColorsr   r   r5   r   r   r   r   r   r   r   r   r   r   r   r!   r"   r   r   r   r  r   r	   r#   r_   r   r  r  r  r>   rZ   staticmethodr.  r_  __classcell__r-   r-   r   r.   r     s    

9
"&

R
D

) n
c                 C   s
  g }d}d}| j  D ]6}|jtjjkrd}n	|r |d d}|jtjjkr*d}n|jtjjkr:|r:|d d}|t	| q|rI|d t
|tdd |D  dkrgd|d	d
d |D }n	d|d|}| jtjurt| j}|d|7 }|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                 s   s    | ]	}t |d  V  qdS )rP   Nr   r;   rr-   r-   r.   r     r   z$_render_signature.<locals>.<genexpr>K   z{}(
{})r~   c                 s   s    | ]}d  |V  qdS )z    {},
N)r   rh  r-   r-   r.   r     s    

z{}({})r(  z -> {})r  r  kindr9   r  POSITIONAL_ONLYr   VAR_POSITIONALKEYWORD_ONLYr5   r   sumr   r   return_annotation_emptyformatannotation)obj_signatureobj_nameresultpos_onlykw_onlyparamrenderedannor-   r-   r.   r     s4   


r   r`  )T)fr^   __all__dataclassesr   r9   r   textwrapr   rE  r   iorp   r   rm   typesrS   typingr   r   r	   r
   r   r   r   r   r   ra  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   r*  r5   r!   r4   r"   r#   r8   FunctionTyper   r2  objectr   r/  
ModuleType
MethodTyper   r1  r+  rJ  r   upperr   Colorsrc  r   r>   r`   r   rV   rX   rY   r3   rh   rx   r:   r   r   r   r   r   r   rk   r   r   r   r-   r-   r-   r.   <module>   s    , 


?

%#      