
    -Ph                    x   U d 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ZddlmZ ddlmZmZmZmZ ddlmZ ddlmZmZ ddlmZ dd	l
mZmZmZ dd
lmZmZmZ ddlm Z! ddl"m#Z# ddl$m%Z% erddlm&Z&m'Z'm(Z( ddlm)Z) ddl
m*Z*m+Z+ ddlm,Z,m-Z-m.Z. ddl/m0Z0 ddl$m1Z1  G d de-          Z2 G d de-          Z3 G d de-          Z4 G d de-          Z5e
j6        e
j7        z  e
j*        z  e
j8        z  e
j9        z  e
j        z  e
j        z  e
j        z  Z:de;d<   e&def         e<eef         z  e=eeef         z  Z>de;d<    e#j?        e@          ZA ejB        d ejC                  ZDejE        ZEejF        ZFejG        ZGejH        ZHejI        ZIdd$ZJdd%dd(ZKdd*ZLdd,ZMdd-ZNdd/ZOdd1ZPdd3ZQdd6ZRdd8ZSdd9ZTdd;ZU	 ddd@ZV	 dddBZW	 dddDZXdddEZY	 dddGZZddIZ[ddJZ\ddMZ]ddNZ^eeefZ_dOe;dP<   ddQZ`ddRZaddTZbddVZcddXZdddZZedd\Zfdd]Zgdd_ZhddaZidddZj ek            deddhZlddjZm G dk dl          Zn G dm dn          Zo G do dp          Zp G dq dreeqef                   ZrddtZs	 	 dddzZt	 	 dddZuddZvddZw	 	 	 	 dddZxddZydddZzddZ{ejduddfddZ|ejfddZ}dS )z&Helpers for inspecting Python modules.    )annotationsN)Mapping)cached_propertypartialpartialmethodsingledispatchmethod)import_module)	Parameter	Signature)StringIO)ClassMethodDescriptorTypeMethodDescriptorTypeWrapperDescriptorType)TYPE_CHECKINGAny
ForwardRef)unparse)logging)stringify_annotation)CallableIteratorSequence)_ParameterKind)
MethodType
ModuleType)FinalProtocol	TypeAlias)TypeIs)_StringifyModec                      e Zd Zd	d
dZdS )_SupportsGet.instancer   ownertype | Nonereturnc                   d S N )selfr#   r$   s      S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/util/inspect.py__get__z_SupportsGet.__get__%             N.)r#   r   r$   r%   r&   r   )__name__
__module____qualname__r,   r)   r.   r+   r"   r"   $   s        QQQQQQQr.   r"   c                      e Zd ZddZdS )	_SupportsSetr#   r   valuer&   Nonec                   d S r(   r)   )r*   r#   r5   s      r+   __set__z_SupportsSet.__set__)   r-   r.   N)r#   r   r5   r   r&   r6   )r0   r1   r2   r8   r)   r.   r+   r4   r4   '   s        DDDDDDr.   r4   c                      e Zd ZddZdS )_SupportsDeleter#   r   r&   r6   c                   d S r(   r)   )r*   r#   s     r+   
__delete__z_SupportsDelete.__delete__-   r-   r.   N)r#   r   r&   r6   )r0   r1   r2   r<   r)   r.   r+   r:   r:   +   s        ;;;;;;r.   r:   c                      e Zd Zd
ddZd	S )_AttrGetter.objr   namestrdefaultr&   c                   d S r(   r)   )r*   r?   r@   rB   s       r+   __call__z_AttrGetter.__call__0   r-   r.   Nr/   )r?   r   r@   rA   rB   r   r&   r   )r0   r1   r2   rD   r)   r.   r+   r>   r>   /   s        RRRRRRRr.   r>   r   _RoutineType._SignatureTypez at 0x[0-9a-f]{8,16}(?=>)r?   r   r&   c                t    t          | d          r| S 	 t          j        |           S # t          $ r | cY S w xY w)zlGet an original object from wrapped object (wrapped functions).

    Mocked objects are returned as is.
    __sphinx_mock__)hasattrinspectunwrap
ValueErrorr?   s    r+   rK   rK   L   sU    
 s%&& 
~c"""   


s   ( 77stoprO   Callable[[Any], bool] | Nonec                   t          |          r ||           svt          |           r| j        } nTt          j        |           rt          | d          r| j        } n(t          |           st          |           r| j	        } n| S  ||           v| S 	 t          |           r| j        } nTt          j        |           rt          | d          r| j        } n(t          |           st          |           r| j	        } n| S l)a  Get an original object from wrapped object.

    Unlike :func:`unwrap`, this unwraps partial functions, wrapped functions,
    class methods and static methods.

    When specified, *stop* is a predicate indicating whether an object should
    be unwrapped or not.
    __wrapped__)
callable	ispartialfuncrJ   	isroutinerI   rR   isclassmethodisstaticmethod__func__)r?   rO   s     r+   
unwrap_allrZ   \   s'    ~~ 
$s)) 	~~ h"3'' GC,G,G os## ~c':': l
 $s)) 	 
S>> 	(CCs## 	](C(C 	/CC3 	>##6#6 	,CCJr.   Sequence[str] | Nonec                    t          | dd          }|dS t          |t          t          z            rt	          d |D                       r|S t          |          )zGet the ``__all__`` attribute of an object as a sequence.

    This returns ``None`` if the given ``obj.__all__`` does not exist and
    raises :exc:`ValueError` if ``obj.__all__`` is not a list or tuple of
    strings.
    __all__Nc              3  @   K   | ]}t          |t                    V  d S r(   
isinstancerA   ).0es     r+   	<genexpr>zgetall.<locals>.<genexpr>   s,      0U0UAs1C1C0U0U0U0U0U0Ur.   )safe_getattrr`   listtupleallrL   )r?   r]   s     r+   getallrh   |   sf     3	400Gt'4%<(( S0U0UW0U0U0U-U-U 
W

r.   Mapping[str, Any]c                V    t          | dd          }t          |t                    r|S i S )z:Safely get the ``__annotations__`` attribute of an object.__annotations__Nrd   r`   r   )r?   rk   s     r+   getannotationsrm      s1    "3(94@@O/7++ Ir.   c                V    t          | dd          }t          |t                    r|S i S )z:Safely get :attr:`obj.__globals__ <function.__globals__>`.__globals__Nrl   )r?   ro   s     r+   
getglobalsrp      s0    sM488K+w'' Ir.   tuple[type, ...]c                V    t          | dd          }t          |t                    r|S dS )z/Safely get :attr:`obj.__mro__ <class.__mro__>`.__mro__Nr)   )rd   r`   rf   )r?   rs   s     r+   getmrort      s/    3	400G'5!! 2r.   tuple[Any, ...] | Nonec                    t          |           sdS t          | di           }|                    d          }t          |t                    rt          |          dk    r|S dS )zSafely get ``obj.__orig_bases__``.

    This returns ``None`` if the object is not a class or if ``__orig_bases__``
    is not well-defined (e.g., a non-tuple object or an empty sequence).
    N__dict____orig_bases__r   )isclassrd   getr`   rf   len)r?   rw   rx   s      r+   getorigbasesr|      sk     3<< t CR00H\\"233N.%(( S-@-@1-D-D4r.   'dict[str, Any] | dict[str, None] | Nonec                4   t          |           st          t          | dd          }|dS t          |t                    r|S t          |t
                    r|diS t          |t          t          z            rt                              |          S t          )a  Safely get :term:`obj.__slots__ <__slots__>` as a dictionary if any.

    - This returns ``None`` if ``obj.__slots__`` does not exist.
    - This raises a :exc:`TypeError` if *obj* is not a class.
    - This raises a :exc:`ValueError` if ``obj.__slots__`` is invalid.
    	__slots__N)
ry   	TypeErrorrd   r`   dictrA   re   rf   fromkeysrL   )r?   r   s     r+   getslotsr      s     3<< S+t44It	It	$	$ 	Is	#	# 4  	Ite|	,	, }}Y'''r.   xTypeIs[type[enum.Enum]]c                T    t          |           ot          | t          j                  S )zACheck if the object is an :class:`enumeration class <enum.Enum>`.)ry   
issubclassenumEnumr   s    r+   isenumclassr      s    1::2*Q	222r.   TypeIs[enum.Enum]c                6    t          | t          j                  S )z0Check if the object is an enumeration attribute.)r`   r   r   r   s    r+   isenumattributer      s    a###r.   c                P    t          |           r| j        } t          |           | S )zGet an original object from a partial-like object.

    If *obj* is not a partial object, it is returned as is.

    .. seealso:: :func:`ispartial`
    )rT   rU   rM   s    r+   	unpartialr      s.     C.. h C.. Jr.   )TypeIs[partial[Any] | partialmethod[Any]]c                <    t          | t          t          z            S )z4Check if the object is a partial function or method.)r`   r   r   rM   s    r+   rT   rT      s    c7]2333r.   clsr@   
str | None"TypeIs[classmethod[Any, Any, Any]]c                4   t          | t                    rdS t          |           r| j        t	          | j                  rdS |rR|rPt                      }t          |          D ]2}|j                            ||          }||urt          |          c S 3dS )z.Check if the object is a :class:`classmethod`.TNF)
r`   classmethodismethod__self__ry   objectrt   rw   rz   rW   r?   r   r@   sentinelbaseclsmeths         r+   rW   rW      s     #{## t}} 1gcl6K6K1t
 +t +88c{{ 	+ 	+G#''h77D8##$T***** $5r.   'TypeIs[types.ClassMethodDescriptorType]c                    t          | t          j                  rdS |r]|r[t                      }t	          |          D ]=}|j                            ||          }||urt          |t          j                  c S >dS )zCheck if the object is a :class:`~types.ClassMethodDescriptorType`.

    This check is stricter than :func:`is_builtin_classmethod_like` as
    a classmethod descriptor does not have a ``__func__`` attribute.
    TF)r`   typesr   r   rt   rw   rz   r   s         r+   is_classmethod_descriptorr      s     #u677 t
 It I88c{{ 	I 	IG#''h77D8##!$(GHHHHH $5r.   boolc                   t          | ||          rdS t          |           r't          | dd          t          | j                  rdS |r|rt                      }t          |          D ]j}|j                            ||          }||urIt          |dd          p5t          |          o&t          |dd          duot          |j                  c S kdS )aE  Check if the object looks like a class method implemented in C.

    This is equivalent to test that *obj* is a class method descriptor
    or is a built-in object with a ``__self__`` attribute that is a type,
    or that ``parent_class.__dict__[name]`` satisfies those properties
    for some parent class in *cls* MRO.
    Tr   NF)	r   	isbuiltingetattrry   r   r   rt   rw   rz   r   s         r+   is_builtin_classmethod_liker     s	    !c400 t#CT**6CL!! 7 t
 
t 
88c{{ 	 	G#''h77D8##0tTBB dOO /j$77tC/..   $ 5r.   c                F    t          | ||          pt          | ||          S )z.Check if the object looks like a class method.)rW   r   )r?   r   r@   s      r+   is_classmethod_liker   -  s'    c4((W,GSRV,W,WWr.   TypeIs[staticmethod[Any, Any]]c                    t          | t                    rdS |r[|rYt                      }t          |d|g          D ]8}|j                            ||          }||urt          |t                    c S 9dS )z/Check if the object is a :class:`staticmethod`.Trs   F)r`   staticmethodr   r   rw   rz   r   s         r+   rX   rX   2  s     #|$$ t  6t 688sIu55 	6 	6G#''h77D8##!$55555 $5r.   5TypeIs[_SupportsGet | _SupportsSet | _SupportsDelete]c                :     t           fddD                       S )z<Check if the object is a :external+python:term:`descriptor`.c              3  T   K   | ]"}t          t          |d                     V  #d S r(   )rS   rd   )ra   itemr   s     r+   rc   zisdescriptor.<locals>.<genexpr>F  sK         	at,,--     r.   )r,   r8   r<   )anyr   s   `r+   isdescriptorr   D  s;        8     r.   c                (    t          | dd          du S )z1Check if the object is an :func:`abstractmethod`.__isabstractmethod__FTrd   rM   s    r+   isabstractmethodr   L  s    3U;;tCCr.   methodr   c                (    t          | dd          duS )z&Check if the method is a bound method.r   Nr   )r   s    r+   isboundmethodr   Q  s    
D11==r.   c                F    	 | j         j        dk    S # t          $ r Y dS w xY w)z6Check if the object is a function or method in cython.cython_function_or_methodF)	__class__r0   AttributeErrorrM   s    r+   is_cython_function_or_methodr   V  s:    }%)DDD   uus    
  zFinal[tuple[type, ...]]_DESCRIPTOR_LIKEc                n   t          j        |           rdS t          |           rt          |           }t	          |          st          |          st          |          rdS t          |          rdS t          |          rdS t          |t                    rdS t          |          j        dk    S dS )z4Check if the object is an attribute-like descriptor.TFinstancemethod)rJ   isdatadescriptorr   rK   
isfunctionr   r   r   ry   r`   r   typer0   )r?   	unwrappeds     r+   isattributedescriptorr   e  s    $$ tC <3KK	i   	Ii$8$8 	HY<O<O 	5'	22 	59 	5i!122 	5I'+;;;5r.   c                    t          j        |           o/t          | d          ot          | d          o| j        j        dk    S )zDCheck if the object is a :func:`~functools.singledispatch` function.dispatchregister	functools)rJ   r   rI   r   r1   rM   s    r+   is_singledispatch_functionr   ~  sO     	3 	3C$$	3C$$	3 L#{2	r.   !TypeIs[singledispatchmethod[Any]]c                ,    t          | t                    S )zBCheck if the object is a :class:`~functools.singledispatchmethod`.)r`   r   rM   s    r+   is_singledispatch_methodr     s    c/000r.   TypeIs[types.FunctionType]c                D    t          j        t          |                     S )zCheck if the object is a user-defined function.

    Partial objects are unwrapped before checking them.

    .. seealso:: :external+python:func:`inspect.isfunction`
    )rJ   r   r   rM   s    r+   r   r     s     inn---r.   !TypeIs[types.BuiltinFunctionType]c                D    t          j        t          |                     S )zCheck if the object is a built-in function or method.

    Partial objects are unwrapped before checking them.

    .. seealso:: :external+python:func:`inspect.isbuiltin`
    )rJ   r   r   rM   s    r+   r   r          Ys^^,,,r.   TypeIs[_RoutineType]c                D    t          j        t          |                     S )zCheck if the object is a kind of function or method.

    Partial objects are unwrapped before checking them.

    .. seealso:: :external+python:func:`inspect.isroutine`
    )rJ   rV   r   rM   s    r+   rV   rV     r   r.   9TypeIs[Callable[..., types.CoroutineType[Any, Any, Any]]]c                V    t          | t                    } t          j        |           S )zDCheck if the object is a :external+python:term:`coroutine` function.rN   )rZ   _is_wrapped_coroutinerJ   iscoroutinefunctionrM   s    r+   r   r     s(     S4
5
5
5C&s+++r.   c                    t          |           st          |           st          |           rdS t          | d          S )z2Check if the object is wrapped coroutine-function.FrR   )rX   rW   rT   rI   rM   s    r+   r   r     sE    c mC00 IcNN  u3&&&r.   'TypeIs[property | cached_property[Any]]c                <    t          | t          t          z            S )z2Check if the object is property (possibly cached).)r`   propertyr   rM   s    r+   
ispropertyr     s    c8o5666r.   TypeIs[types.GenericAlias]c                P    t          | t          j        t          j        z            S )z'Check if the object is a generic alias.)r`   r   GenericAliastyping_BaseGenericAliasrM   s    r+   isgenericaliasr     s    c5-0HHIIIr.   rA   defargsc                0   t          |          dk    r!dt          |           }t          |          	 t          | |g|R  S # t          $ rG}	 | j        |         cY d}~S # t          $ r Y nw xY w|r|d         cY d}~S t          |          |d}~ww xY w)z;A getattr() that turns all exceptions into AttributeErrors.   z/safe_getattr expected at most 3 arguments, got Nr   )r{   r   r   	Exceptionrw   r   )r?   r@   r   msgexcs        r+   rd   rd     s    
7||aNGNNnn,sD+7++++ , , ,	 <%%%%%%% 	 	 	D	
  	1:T""+,sA   A 
BA!B!
A.+B-A..B:B BB_seenr   frozenset[int]c                   |t           t                    rt                     v rdS t                     hz  	 t                     }n$# t          $ r t           fd          }Y nw xY w fd|D             }dd                    d |D                       z  S t           t                    rt                     v rdS t                     hz  	 t                     }n$# t          $ r t           fd	          }Y nw xY wdd                    fd
|D                       z  S t           t                    rt                     v rdS t                     hz  	 t                     }n$# t          $ r t           fd          }Y nw xY wdd                    fd|D                       z  S t           t          j	                  rB j
        j        t          j	        j
        urt                     S  j        j         d j         S t           t                     r|t                     v rdS t          t                     g          z  d                    d                    fd D                       dt%                     dk    z            S t           t&                    rJt                     v rdS t                     hz  dd                    fd D                       z  S 	 t                     }n# t(          $ r}t*          |d}~ww xY wt,                              d|          }|                    dd          S )zA repr() implementation that returns text safe to use in reST context.

    Maintains a set of 'seen' object IDs to detect and avoid infinite recursion.
    z	dict(...)c                &    t          |           S Nr   object_description)kseens    r+   <lambda>z$object_description.<locals>.<lambda>  s    4FqPT4U4U4U r.   )keyc              3  h   K   | ],}t          |           t          |                    fV  -dS r   Nr   )ra   r   r?   r   s     r+   rc   z%object_description.<locals>.<genexpr>  s_       
 

  #3d333"3s84888
 
 
 
 
 
r.   z{%s}, c              3  *   K   | ]\  }}| d | V  dS ): Nr)   )ra   r   r5   s      r+   rc   z%object_description.<locals>.<genexpr>  s4      !N!NeS"3"3E"3"3!N!N!N!N!N!Nr.   zset(...)c                &    t          |           S r   r   r   r   s    r+   r   z$object_description.<locals>.<lambda>       6HRV6W6W6W r.   c              3  :   K   | ]}t          |           V  dS r   r   ra   r   r   s     r+   rc   z%object_description.<locals>.<genexpr>  sB       "
 "
23q---"
 "
 "
 "
 "
 "
r.   zfrozenset(...)c                &    t          |           S r   r   r   s    r+   r   z$object_description.<locals>.<lambda>  r   r.   zfrozenset({%s})c              3  :   K   | ]}t          |           V  dS r   r   r   s     r+   rc   z%object_description.<locals>.<genexpr>  sB       -
 -
23q----
 -
 -
 -
 -
 -
r.   .z
tuple(...)z({}{})c              3  :   K   | ]}t          |           V  dS r   r   r   s     r+   rc   z%object_description.<locals>.<genexpr>  s1      EEA($777EEEEEEr.   ,r   z	list(...)z[%s]c              3  :   K   | ]}t          |           V  dS r   r   r   s     r+   rc   z%object_description.<locals>.<genexpr>   s1      !Q!Q"4Qd"C"C"C!Q!Q!Q!Q!Q!Qr.   N 
 )r`   r   idsortedr   joinset	frozensetr   r   __repr__rY   reprr   r0   r@   rf   formatr{   re   r   rL   memory_address_resubreplace)r?   r   sorted_keysitemssorted_valuessr   r   s   `      @r+   r   r     s;   
 D#t :Rc77d??;C		W ++KK 	W 	W 	W *U*U*U*UVVVKKK	W
 
 
 
 

 #
 
 
 		!N!N!N!N!NNNNN	C		 (Rc77d??:C		Y"3KKMM 	Y 	Y 	Y"3,W,W,W,WXXXMMM	Y 		 "
 "
 "
 "
7D"
 "
 "
 
 
 
 	
 
C	#	# Rc77d??##C		Y"3KKMM 	Y 	Y 	Y"3,W,W,W,WXXXMMM	Y !499 -
 -
 -
 -
7D-
 -
 -
 $
 $
 
 	
 
C	#	# R< 	(:::99-(5538555	C		 Rc77d??<	2c77)$$$IIEEEEEEEEE3s88q=!
 
 	
 
C		 Rc77d??;C			!Q!Q!Q!QS!Q!Q!QQQQQ"II " " "c!" 	b!$$A99T3sN   A A21A2"C2 2DD6F F'&F'L+ +
M5L==M	attr_namec                    t          |           }	 t          fd|D                       }n# t          $ r Y dS w xY w	 t          |d          }n# t          $ r Y dS w xY wt          t          |d          |u S )a  Check whether *attr_name* is implemented on a builtin class.

        >>> is_builtin_class_method(int, '__init__')
        True


    This function is needed since CPython implements ``int.__init__`` via
    descriptors, but PyPy implementation is written in pure Python code.
    c              3  B   K   | ]}t          |d i           v |V  dS )rw   Nr   )ra   cr  s     r+   rc   z*is_builtin_class_method.<locals>.<genexpr>9  s9      RRY,q*b2Q2Q%Q%Q1%Q%Q%Q%QRRr.   Fr0   N)rt   nextStopIterationrd   r   r   builtins)r?   r  mror   r@   s    `   r+   is_builtin_class_methodr!  ,  s     ++CRRRRcRRRRR   uuC,,   uu 8T4((C//s   . 
<< A 
AAc                  2    e Zd ZdZddZdd
ZddZddZdS )DefaultValuezKA simple wrapper for default value of the parameters of overload functions.r5   rA   r&   r6   c                    || _         d S r(   r5   )r*   r5   s     r+   __init__zDefaultValue.__init__H  s    


r.   otherr   r   c                    | j         |k    S r(   r%  r*   r'  s     r+   __eq__zDefaultValue.__eq__K  s    zU""r.   intc                *    t          | j                  S r(   )hashr5   r*   s    r+   __hash__zDefaultValue.__hash__N  s    DJr.   c                    | j         S r(   r%  r.  s    r+   r  zDefaultValue.__repr__Q  s
    zr.   N)r5   rA   r&   r6   r'  r   r&   r   r&   r+  r&   rA   )r0   r1   r2   __doc__r&  r*  r/  r  r)   r.   r+   r#  r#  E  sj        UU   # # # #            r.   r#  c                  :    e Zd ZdZddZddZddZddZddZdS )TypeAliasForwardRefzPseudo typing class for :confval:`autodoc_type_aliases`.

    This avoids the error on evaluating the type inside :func:`typing.get_type_hints()`.
    r@   rA   r&   r6   c                    || _         d S r(   r@   )r*   r@   s     r+   r&  zTypeAliasForwardRef.__init__[  s    			r.   c                    d S r(   r)   r.  s    r+   rD   zTypeAliasForwardRef.__call__^  s    r.   r'  r   r   c                    | j         |k    S r(   r8  r)  s     r+   r*  zTypeAliasForwardRef.__eq__b  s    yE!!r.   r+  c                *    t          | j                  S r(   )r-  r@   r.  s    r+   r/  zTypeAliasForwardRef.__hash__e  s    DIr.   c                0    | j         j         d| j        dS )N())r   r0   r@   r.  s    r+   r  zTypeAliasForwardRef.__repr__h  s     .)::DI::::r.   N)r@   rA   r&   r6   )r&   r6   r1  r2  r3  )	r0   r1   r2   r4  r&  rD   r*  r/  r  r)   r.   r+   r6  r6  U  s         
      " " " "   ; ; ; ; ; ;r.   r6  c                  "    e Zd ZdZddZddZdS )TypeAliasModulez8Pseudo module class for :confval:`autodoc_type_aliases`.modnamerA   mappingMapping[str, str]r&   r6   c                0    || _         || _        d | _        d S r(   )_TypeAliasModule__modname_TypeAliasModule__mapping_TypeAliasModule__module)r*   rA  rB  s      r+   r&  zTypeAliasModule.__init__o  s      +/r.   r@   r   c                   d                     t          d | j        |g                    }|| j        v rt	          | j        |                   S |dz   fd| j                                        D             }|rt          ||          S 	 t          |          S # t          $ r8 | j	        t          | j                  | _	        t          | j	        |          cY S w xY w)Nr  c                F    i | ]\  }}|                               ||S r)   
startswithra   r   vprefixs      r+   
<dictcomp>z/TypeAliasModule.__getattr__.<locals>.<dictcomp>|  0    VVVtq!fAUAUVaVVVr.   )r  filterrE  rF  r6  r  r@  r	   ImportErrorrG  r   )r*   r@   fullnamenestedrN  s       @r+   __getattr__zTypeAliasModule.__getattr__u  s    88F4$.$)?@@AAt~%%&t~h'?@@@^FVVVVt~';';'='=VVVF 8&x8888(222" 8 8 8},(5dn(E(E"4=$777778s   B ?CCN)rA  rA   rB  rC  r&   r6   )r@   rA   r&   r   )r0   r1   r2   r4  r&  rU  r)   r.   r+   r@  r@  l  sB        BB0 0 0 08 8 8 8 8 8r.   r@  c                  D     e Zd ZdZd fdZdd
ZddZddZddZ xZ	S )TypeAliasNamespacezPseudo namespace class for :confval:`autodoc_type_aliases`.

    Useful for looking up nested objects via ``namespace.foo.bar.Class``.
    rB  rC  r&   r6   c                V    t                                                       || _        d S r(   )superr&  _TypeAliasNamespace__mapping)r*   rB  r   s     r+   r&  zTypeAliasNamespace.__init__  s$     r.   r   r   r   c                   t          |t                    st          || j        v rt	          | j        |                   S |dz   fd| j                                        D             }|rt          ||          S t          )Nr  c                F    i | ]\  }}|                               ||S r)   rJ  rL  s      r+   rO  z2TypeAliasNamespace.__getitem__.<locals>.<dictcomp>  rP  r.   )r`   rA   KeyErrorrZ  r6  r  r@  )r*   r   rT  rN  s      @r+   __getitem__zTypeAliasNamespace.__getitem__  s    #s## 	N$.  &t~c':;;;3YFVVVVt~';';'='=VVVF &sF333r.   r   c                    t          |t                    sdS | j        }| d||v pt          fd|D                       S )NFr  c              3  B   K   | ]}|                               V  d S r(   rJ  )ra   r   rN  s     r+   rc   z2TypeAliasNamespace.__contains__.<locals>.<genexpr>  s/      AAV 4 4AAAAAAr.   )r`   rA   rZ  r   )r*   r   nsrN  s      @r+   __contains__zTypeAliasNamespace.__contains__  sX    #s## 	5^byACAAAAbAAAAAAr.   Iterator[str]c              #     K   | j         D ]L}|V  t          |                    d                    D ]#}|                    d|dz             d         V  $Md S )Nr  r   r   )rZ  rangecountrsplit)r*   r   is      r+   __iter__zTypeAliasNamespace.__iter__  sv       	. 	.AGGG1773<<(( . .hhsAE**1-----.	. 	.r.   r+  c                >    t          d | j        D                       S )Nc              3  F   K   | ]}|                     d           dz   V  dS )r  r   N)rf  )ra   r   s     r+   rc   z-TypeAliasNamespace.__len__.<locals>.<genexpr>  s1      <<1773<<!#<<<<<<r.   )sumrZ  r.  s    r+   __len__zTypeAliasNamespace.__len__  s!    <<T^<<<<<<r.   )rB  rC  r&   r6   )r   r   r&   r   )r   r   r&   r   )r&   rc  r2  )
r0   r1   r2   r4  r&  r^  rb  ri  rm  __classcell__)r   s   @r+   rW  rW    s         
! ! ! ! ! !   B B B B. . . .= = = = = = = =r.   rW  subjectc                    t          |           }|                    d          dk    o"|                    d          t          j        k    S )z<Check the function should be unwrapped on getting signature.r0   
contextlib__file__)rp   rz   rq  rr  )ro  ro   s     r+   _should_unwraprs    sF    W%%K 	
##|3 	?OOJ'':+>>r.   Fbound_methodtype_aliasesMapping[str, str] | Noner   c                   |i }	 t          |           rt          j        |           }nt          j        | d          }n$# t          $ r t          j        |           }Y nw xY wt	          |j                                                  }|j        }	 t          |          }t          j
        | d|d          }t          |          D ]P\  }}	|	j        |v rB||	j                 }
t          |
t                    r|
j        }
|	                    |
          ||<   Qd|v r1t          |d         t                    r|d         j        }n|d         }n# t           $ r Y nw xY w|rQt          j        |           s=t          j        |           rn(t'          |          dk    r|                    d           t+          ||d	          S )
zReturn a Signature object for the given *subject*.

    :param bound_method: Specify *subject* is a bound method or not.

    When *subject* is a built-in callable, *bound_method* is ignored.
    NT)follow_wrapped)include_extras
annotationr&   r   F)return_annotation__validate_parameters__)rs  rJ   	signaturerL   re   
parametersvaluesr|  rW  r   get_type_hints	enumerater@   r`   r6  r  r   r   r   r{   popr   )ro  rt  ru  r~  r  r|  localnsr   rh  paramr{  s              r+   r~  r~    s    /'"" 	H)'22II)'$GGGI / / /%g..			/ i*113344J!3$\22+GT7SWXXX!*-- 	E 	EHAuz[(((4
j*=>> 1!+J % D D
1{""+h/1DEE :$/$9$>!!$/$9!    	  "G-g66 "G$$ 	" :""q!!! &7QV   s$   :A A"!A"B<E 
EEsigglobalnsdict[str, Any] | Noner  c                V   |i }||}t          | j                                                  }t          |          D ];\  }}|j        r/t          |j        ||          }|                    |          ||<   <| j        }|rt          |||          }|                     ||          S )z;Evaluate unresolved type annotations in a signature object.Nrz  )r  r|  )re   r  r  r  r{  	_evaluater  r|  )r  r  r  r  rh  r  r{  r|  s           r+   evaluate_signaturer    s     cn++--..Jj)) A A5 	A"5#3XwGGJ!MMZM@@JqM- L%&77KK;;*@Q;RRRr.   refr   c                   t           j        dd         dk    rt          j        | ||          S t           j        dk    r%|                     ||dt                                S |                     ||t                                S )	zEvaluate a forward reference.N   )      )globalslocals)r        r)   )type_paramsrecursive_guard)r  )sysversion_infor   evaluate_forward_refr  r  )r  r  r  s      r+   _evaluate_forwardrefr    s     w&& *3QQQQ
:%% }}g2y{{  
 
 	
 ==7IKK=HHHr.   r{  dict[str, Any]c                Z   	 t          | t                    r|t          |           }t          |||          } t          | t                    rt          |||          } n5t          | t                    r t          |           }t          |||          } n# t          t
          f$ r Y nw xY w| S )z$Evaluate unresolved type annotation.)r`   rA   r   r  	NameErrorr   )r{  r  r  r  s       r+   r  r  2  s    j#&& 		JZ((C-c8WEEJ*j11 J1#xII

J,, J ,,1#xII
y!    s   BB B('B(Tshow_annotationshow_return_annotationunqualified_typehintsshort_literalsc                   |rd}nd}t           j        }g }d}| j                                        D ]}	|	j        t           j        k    r%|t           j        k    r|                    d           |	j        t           j        k    r0|t           j        t           j        dhv r|                    d           t                      }
|	j        t           j
        u r|
                    d|	j        z              nK|	j        t           j        u r|
                    d|	j        z              n|
                    |	j                   |rH|	j        |ur?|
                    d           |
                    t          |	j        ||                     |	j        |ur]|r|	j        |ur|
                    d	           n|
                    d
           |
                    t#          |	j                             |                    |
                                           |	j        }|t           j        u r|                    d           d                    |          }| j        |u s|r|sd| dS t          | j        ||          }d| d| S )a  Stringify a :class:`~inspect.Signature` object.

    :param show_annotation: If enabled, show annotations on the signature
    :param show_return_annotation: If enabled, show annotation of the return value
    :param unqualified_typehints: If enabled, show annotations as unqualified
                                  (ex. io.StringIO -> StringIO)
    :param short_literals: If enabled, use short literal types.
    smartzfully-qualifiedN/*z**r   )r  z = =r   r=  r>  z) -> )r
   emptyr  r  kindPOSITIONAL_ONLYappendKEYWORD_ONLYPOSITIONAL_OR_KEYWORDr   VAR_POSITIONALwriter@   VAR_KEYWORDr{  r   rB   r   getvaluer  r|  )r  r  r  r  r  modeEMPTYargs	last_kindr  argconcatenated_argsretanns                r+   stringify_signaturer  J  s      ! OEDI&&(( & &J)333Y666 KK:///I+%B
 5
 5
 KKjj:111IIcEJ&''''Z9000IIdUZ'((((IIej!!! 	u/u<<IIdOOOII$$d>    
 =%% 5#35#@#@		%    		#II(77888CLLNN###J		I---C		$&& 	'% 	' ($''''%!4
 
 
 4$336333r.   r~  c                    d| z   dz   }t          j        |          }t          j        d|j        d                   }t          ||          S )z:Create a :class:`~inspect.Signature` object from a string.zdef funcz: passast.FunctionDefr   )astparser   castbodysignature_from_ast)r~  codemodulefunctions       r+   signature_from_strr    sF    	!H,DYt__F{,fk!n==Hh---r.   r  noder  r  c           	        t           j        }| j        }t          |j                  }t          |j                  }|t          |j                  z   t          |          z
  }d|z  |z   }g }t          |j        |d          D ]5\  }}	|                    t          t           j
        |||	                     6t          |j        ||d         d          D ]5\  }}	|                    t          t           j        |||	                     6|j        r5|                    t          t           j        |j        |d                     t          |j        |j        d          D ]5\  }}	|                    t          t           j        |||	                     6|j        r5|                    t          t           j        |j        |d                     t'          | j        |          p|}
t+          ||
          S )z=Create a :class:`~inspect.Signature` object from an AST node.r(   F)strict)defexprN)r|  )r
   r  r  rf   defaultsr{   posonlyargszipr  _definer  r  varargr  
kwonlyargskw_defaultsr  kwargr  ast_unparsereturnsr   )r  r  r  r  r  pos_only_offsetdefaults_offsetparamsr  r  r|  s              r+   r  r    s   OE)D,1$-,@,@H$*++O%DI6XFO (83H !F D,huEEE V VWgi7dGTTTUUUU DIx0@0@'A%PPP 
 
WI3S$PPP	
 	
 	
 	

 { 
I,dk4NNN	
 	
 	

 DOT-=eLLL S SWgi4c4QQQRRRR z Vgi3TZtTTTUUU#DL$77@5V/@AAAAr.   r  r   r  ast.argr  ast.expr | Noner
   c                   t           j        }||nt          t          ||                    }t          |j        |          p|}t          |j        | ||          S )N)rB   r{  )r
   r  r#  r  r{  r  )r  r  r  r  r  rB   r{  s          r+   r  r    sY     OEeeLWd9S9S,T,TGS^T22;eJSWdG
KKKKr.   
attrgetterallow_inheritedc                   |r|rt          | ||          rtt          |          D ]d}|j                            |          }|st	          |d          st          |          r&t          t          |d|                    }||s|c S et          |           }t          |           r$|| j
        j        k    rt          | j                  S ||r|ry|rwt          |          D ](}t          ||d          }|t          |          }| n)|=t          |          D ]-}t          ||d          }|t          j        |          }| n.|t          j        |           }|S )zGet the docstring for the object.

    This tries to obtain the docstring for some kind of objects additionally:

    * partial functions
    * inherited docstring
    * inherited decorated methods
    rY   N)r   rt   rw   rz   rI   r   getdocr   _getdoc_internalrT   r   r4  rU   rd   rJ   )r?   r  r  r   r@   r   r   docs           r+   r  r    s     
t 
+Cd;; 
c{{ 		 		G#''--D  tZ(( ,Ed,K,K "(z4)H)H"I"I?/?JJJ
3

C~~ &#!666ch	 	"4 	"!#;;  #GT488#*400C{%c{{ " "G't<<D'%nT22?!E;.%%CJr.   Callable[[Any, str, Any], Any]c                N     || dd           }t          |t                    r|S d S )Nr4  r_   )r?   r  r  s      r+   r  r    s3     *S)T
*
*C#s 
4r.   )r?   r   r&   r   )r?   r   rO   rP   r&   r   )r?   r   r&   r[   )r?   r   r&   ri   )r?   r   r&   rq   )r?   r   r&   ru   )r?   r   r&   r}   )r   r   r&   r   )r   r   r&   r   )r?   r   r&   r   )NN)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   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   )r?   r   r&   r   )r?   r   r&   r   )r?   r   r&   r   )r?   r   r&   r   )r?   r   r&   r   )r?   r   r@   rA   r   r   r&   r   )r?   r   r   r   r&   rA   )r?   r   r  rA   r&   r   )ro  rF   r&   r   )FN)ro  rF   rt  r   ru  rv  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   )TTFF)r  r   r  r   r  r   r  r   r  r   r&   rA   )r~  rA   r&   r   )r  )r  r  r  rA   r&   r   )
r  r   r  r  r  rA   r  r  r&   r
   )r?   r   r  r>   r  r   r   r   r@   r   r&   r   )r?   r   r  r  r&   r   )~r4  
__future__r   r  r  rq  r   rJ   rer  r   r   collections.abcr   r   r   r   r   r   	importlibr	   r
   r   ior   r   r   r   r   r   r   sphinx.pycode.astr   r  sphinx.utilr   sphinx.util.typingr   r   r   r   r   r   r   r   r   r   typing_extensionsr   r    r"   r4   r:   r>   FunctionType
LambdaTypeBuiltinFunctionTypeBuiltinMethodTyperE   rk   r   r   rF   	getLoggerr0   loggercompile
IGNORECASEr  isasyncgenfunctionr   ismethoddescriptorry   ismodulerK   rZ   rh   rm   rp   rt   r|   r   r   r   r   rT   rW   r   r   r   rX   r   r   r   r   r   r   r   r   r   r   rV   r   r   r   r   rd   r  r   r!  r#  r6  r@  rA   rW  rs  r~  r  r  r  r  r  r  r  r  r  r)   r.   r+   <module>r     s   , , , " " " " " " 



        				 



   # # # # # # S S S S S S S S S S S S # # # # # # ( ( ( ( ( ( ( (       X X X X X X X X X X 1 1 1 1 1 1 1 1 1 1 4 4 4 4 4 4       3 3 3 3 3 3 $<<<<<<<<<<&&&&&&,,,,,,,,1111111111((((((111111R R R R Rx R R RE E E E Ex E E E< < < < <( < < <S S S S Sh S S S 	

	

	 
#	$ 
!		"
 
%	& 
$	% 
)	*  	 	 	 	 	c\#s(33k#sC-6PP      
	8	$	$BJ;R]KK  / / 
/     BF      @               $   .3 3 3 3
$ $ $ $
	 	 	 	4 4 4 4 37    & 37    * 37    @X X X X X 37    $   D D D D
> > > >
    -        2   1 1 1 1
. . . .- - - -- - - -, , , ,' ' ' '7 7 7 7
J J J J
, , , ,4 =FIKK I  I  I  I  I  I X0 0 0 02        ; ; ; ; ; ; ; ;.8 8 8 8 8 8 8 8B'= '= '= '= '=c* '= '= '=T    -1@ @ @ @ @J '+%)S S S S S0I I I I,   4 !#'"' P4 P4 P4 P4 P4f. . . .0B 0B 0B 0B 0BfL L L L  +!4 4 4 4 4p <H      r.   