
    Feq                    \   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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mZmZmZmZ ddlmZ dd	l
mZmZ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,m-Z-  e*j\                  e/      Z0 ejb                  dejd                        Z3d@dZ4dddAdZ5dBdZ6dCdZ7dCdZ8dDdZ9dEdZ:dFdZ;dGdZ<dHdZ=dHdZ>d@dZ?dGdZ@dIdJdZAdIdJdZBdHdZCdGd ZDdKd!ZEdGd"ZFdGd#ZGdGd$ZHdGd%ZIdGd&ZJdGd'ZKdGd(ZLdGd)ZMdGd*ZNdGd+ZOdLd,ZP eQ       d-dMd.ZRdNd/ZS G d0 d1      ZT G d2 d3      ZU G d4 d5      ZV G d6 d7eWeXe#f         ZYdOd8ZZdP	 dQd:Z[	 	 dI	 	 	 dRd;Z\	 	 	 dS	 	 	 	 	 dTd<Z]dUd=Z^dVdWd>Z_ePd9ddf	 	 	 	 	 	 	 	 	 	 	 dXd?Z`y)Yz&Helpers for inspecting Python modules.    )annotationsN)MappingSequence)cached_propertypartialpartialmethodsingledispatchmethod)import_module)	Parameterisasyncgenfunctionisclassismethodismethoddescriptorismodule)StringIO)ClassMethodDescriptorTypeMethodDescriptorType
MethodType
ModuleTypeWrapperDescriptorType)AnyCallablecast)unparse)logging)
ForwardRefstringify_annotationz at 0x[0-9a-f]{8,16}(?=>)c                l    t        | d      r| S 	 t        j                  |       S # t        $ r | cY S w xY w)z?Get an original object from wrapped object (wrapped functions).__sphinx_mock__)hasattrinspectunwrap
ValueErrorobjs    5/usr/lib/python3/dist-packages/sphinx/util/inspect.pyr"   r"   ,   s:    s%&
~~c"" 
s   % 33stopc                   	 |r
 ||       r| S t        |       r| j                  } nSt        j                  |       rt	        | d      r| j
                  } n%t        |       st        |       r| j                  } n| S x)zx
    Get an original object from wrapped object (unwrapping partials, wrapped
    functions, and other decorators).
    __wrapped__)		ispartialfuncr!   	isroutiner    r*   isclassmethodisstaticmethod__func__)r%   r(   s     r&   
unwrap_allr1   8   sg    
 DIJS>((Cs#](C//C3>##6,,CJ     c                    t        | dd      }|yt        |t        t        f      rt	        d |D              r|S t        |      )zGet __all__ attribute of the module as dict.

    Return None if given *obj* does not have __all__.
    Raises ValueError if given *obj* have invalid __all__.
    __all__Nc              3  <   K   | ]  }t        |t                y wN
isinstancestr).0es     r&   	<genexpr>zgetall.<locals>.<genexpr>S   s     1V*Q2D1Vs   )safe_getattrr8   listtupleallr#   )r%   r4   s     r&   getallrA   J   sE     3	40G'D%=)c1Vg1V.V
W
r2   c                D    t        | dd      }t        |t              r|S i S )z,Get __annotations__ from given *obj* safely.__annotations__Nr=   r8   r   )r%   rC   s     r&   getannotationsrE   X   s&    "3(94@O/7+	r2   c                D    t        | dd      }t        |t              r|S i S )z(Get __globals__ from given *obj* safely.__globals__NrD   )r%   rG   s     r&   
getglobalsrH   a   s%    sM48K+w'	r2   c                B    t        | dd      }t        |t              r|S y)z$Get __mro__ from given *obj* safely.__mro__N )r=   r8   r?   )r%   rJ   s     r&   getmrorL   j   s"    3	40G'5!r2   c                    t        j                  |       syt        | di       }|j                  d      }t	        |t
              rt        |      dkD  r|S y)z%Get __orig_bases__ from *obj* safely.N__dict____orig_bases__r   )r!   r   r=   getr8   r?   len)r%   rN   rO   s      r&   getorigbasesrR   s   sO    ??3 CR0H\\"23N.%(S-@1-Dr2   c                   t        j                  |       st        t        | dd      }|yt	        |t
              r|S t	        |t              r|diS t	        |t        t        f      rt
        j                  |      S t        )zGet __slots__ attribute of the class as dict.

    Return None if gienv *obj* does not have __slots__.
    Raises TypeError if given *obj* is not a class.
    Raises ValueError if given *obj* have invalid __slots__.
    	__slots__N)r!   r   	TypeErrorr=   r8   dictr9   r>   r?   fromkeysr#   )r%   rT   s     r&   getslotsrX      st     ??3S+t4I	It	$	Is	#4  	Ie}	-}}Y''r2   c                    t         j                  dd dk\  rt        | t        j                        S t        | dd      }t        | dd      }|dk(  xr |dk(  S )z)Check the if object is a kind of NewType.N   )   
   
__module____qualname__typingzNewType.<locals>.new_type)sysversion_infor8   r_   NewTyper=   )r%   r]   r^   s      r&   	isNewTyperc      sZ    
w&#v~~..c<6J^T:L!Ql6Q&QQr2   c                d    t        j                  |       xr t        | t        j                        S )z(Check if the object is subclass of enum.)r!   r   
issubclassenumEnumxs    r&   isenumclassrj      s!    ??1:*Q		"::r2   c                6    t        | t        j                        S )z)Check if the object is attribute of enum.)r8   rf   rg   rh   s    r&   isenumattributerl      s    a##r2   c                L    t        |       r| j                  } t        |       r| S )zfGet an original object from partial object.

    This returns given object itself if not partial.
    )r+   r,   r$   s    r&   	unpartialrn      s$    
 C.hh C. Jr2   c                .    t        | t        t        f      S )zCheck if the object is partial.)r8   r   r   r$   s    r&   r+   r+      s    cG]344r2   c                *   t        | t              ryt        j                  |       r"| j                  t        | j                        ry|rI|rGt               }t        |      D ]/  }|j                  j                  ||      }||us$t        |      c S  y)z#Check if the object is classmethod.TF)r8   classmethodr!   r   __self__r   objectrL   rN   rP   r.   )r%   clsnameplaceholderbaseclsmeths         r&   r.   r.      s    #{#!9gcll>S
thc{ 	+G##''k:D;&$T**	+
 r2   c                    t        | t              ry|rD|rBt        |d|g      D ]1  }|j                  j	                  |      }|s!t        |t              c S  y)z$Check if the object is staticmethod.TrJ   F)r8   staticmethodgetattrrN   rP   )r%   rt   ru   rw   rx   s        r&   r/   r/      s[    #|$
t sIu5 	6G##''-D!$55	6 r2   c                ,     t         fddD              S )z/Check if the object is some kind of descriptor.c              3  J   K   | ]  }t        t        |d               y wr6   )callabler=   )r:   itemri   s     r&   r<   zisdescriptor.<locals>.<genexpr>   s'       	at,-s    #)__get____set__
__delete__)anyrh   s   `r&   isdescriptorr      s     8  r2   c                     t        | dd      du S )z)Check if the object is an abstractmethod.__isabstractmethod__FTr=   r$   s    r&   isabstractmethodr      s    3U;tCCr2   c                     t        | dd      duS )z&Check if the method is a bound method.rr   Nr   )methods    r&   isboundmethodr      s    
D1==r2   c                T    	 | j                   j                  dk(  S # t        $ r Y yw xY w)z6Check if the object is a function or method in cython.cython_function_or_methodF)	__class____name__AttributeErrorr$   s    r&   is_cython_function_or_methodr      s/    }}%%)DDD s    	''c                d   t        j                  |       ryt        |       rt        |       }t	        |      s t        |      st        j                  |      ryt        |      ryt        j                  |      ryt        |t        t        t        f      ryt        |      j                  dk(  ryyy)z4Check if the object is an attribute like descriptor.TFinstancemethod)r!   isdatadescriptorr   r"   
isfunction	isbuiltinr   r   r   r8   r   r   r   typer   )r%   	unwrappeds     r&   isattributedescriptorr      s    $C3K	i Ii$8G<L<LY<W'	2??9%i";"6"7"9 : 	?##'77r2   c                    t        j                  |       xr5 t        | d      xr' t        | d      xr | j                  j                  dk(  S )z/Check if the object is singledispatch function.dispatchregister	functools)r!   r   r    r   r]   r$   s    r&   is_singledispatch_functionr     sL    s# 3C$3C$3 LL##{24r2   c                "    t        | t              S )z-Check if the object is singledispatch method.)r8   r	   r$   s    r&   is_singledispatch_methodr     s    c/00r2   c                >    t        j                  t        |             S z Check if the object is function.)r!   r   rn   r$   s    r&   r   r     s    in--r2   c                >    t        j                  t        |             S r   )r!   r   rn   r$   s    r&   r   r   $      Ys^,,r2   c                >    t        j                  t        |             S )z(Check is any kind of function or method.)r!   r-   rn   r$   s    r&   r-   r-   )  r   r2   c                N    dd}t        | |      } t        j                  |       S )z*Check if the object is coroutine-function.c                ^    t        |       st        |       st        |       ryt        | d      S )z2Check if the object is wrapped coroutine-function.Fr*   )r/   r.   r+   r    r$   s    r&   iswrappedcoroutinez/iscoroutinefunction.<locals>.iswrappedcoroutine0  s)    #-"4	# sM**r2   r'   r%   r   returnbool)r1   r!   iscoroutinefunction)r%   r   s     r&   r   r   .  s'    + S1
2C&&s++r2   c                .    t        | t        t        f      S )z Check if the object is property.)r8   propertyr   r$   s    r&   
ispropertyr   <  s    cHo677r2   c                V    t        | t        j                  t        j                  f      S )z$Check if the object is GenericAlias.)r8   typesGenericAliasr_   _BaseGenericAliasr$   s    r&   isgenericaliasr   A  s%    e  &":":;= =r2   c                    	 t        | |g| S # t        $ rA}	 | 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.Nr   )r{   	ExceptionrN   r   )r%   ru   defargsexcs       r&   r=   r=   G  sm    ,sD+7++ ,	 <<%% 		
 1:T"+,s6    	A-A	9A9	AAAA_seenc               V    |t         t              rPt               v ryt               hz  	 t               } fd|D        }ddj                  d |D              z  S t         t              rFt               v ryt               hz  	 t               }ddj                  fd
|D              z  S t         t              rFt               v ryt               hz  	 t               }ddj                  fd|D              z  S t         t        j                        r% j                  j                   d j                   S t         t              rUt               v ryt        t               g      z  ddj                  fd D              dt               dk(  z  dS t         t              r:t               v ryt               hz  ddj                  fd D              z  S 	 t!               }t&        j)                  d|      }|j+                  dd      S # t        $ r t         fd      }Y w xY w# t        $ r t         fd	      }Y w xY w# t        $ r t         fd      }Y w xY w# t"        $ r}t$        |d}~ww xY w)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>k  s    4FqPT4U r2   )keyc              3  X   K   | ]!  }t        |       t        |          f # ywr   Nr   )r:   r   r%   r   s     r&   r<   z%object_description.<locals>.<genexpr>m  s5      T@C %S5$SXT:< Ts   '*z{%s}, c              3  0   K   | ]  \  }}| d |   yw): NrK   )r:   r   values      r&   r<   z%object_description.<locals>.<genexpr>o  s     !NeSEE7"3!Ns   zset(...)c                    t        |       S r   r   ri   r   s    r&   r   z$object_description.<locals>.<lambda>x      6HRV6W r2   c              3  8   K   | ]  }t        |         ywr   r   r:   ri   r   s     r&   r<   z%object_description.<locals>.<genexpr>y  s     !["4Qd"C"C![   zfrozenset(...)c                    t        |       S r   r   r   s    r&   r   z$object_description.<locals>.<lambda>  r   r2   zfrozenset({%s})c              3  8   K   | ]  }t        |         ywr   r   r   s     r&   r<   z%object_description.<locals>.<genexpr>  s&      -E12 .@-N-N -Er   .z
tuple(...)(c              3  8   K   | ]  }t        |         ywr   r   r   s     r&   r<   z%object_description.<locals>.<genexpr>  s     EA($77Er   ,   )z	list(...)z[%s]c              3  8   K   | ]  }t        |         ywr   r   r   s     r&   r<   z%object_description.<locals>.<genexpr>  s     !Q"4Qd"C"C!Qr   N 
 )r8   rV   idsortedrU   joinset	frozensetrf   rg   r   r   ru   r?   rQ   r>   reprr   r#   memory_address_resubreplace)r%   r   sorted_keysitemssorted_valuessr   r   s   `      @r&   r   r   ]  s   
 D#tc7d?C		W +K
TGRT		!N!NNNN	C	c7d?C		Y"3KM 		![]![[[[	C	#c7d?#C		Y"3KM !499 -E6C-E $E E 	E	C	#--(()388*55	C	c7d?	2c7)$$IIEEE3s8q=!
 	
 
C	c7d?C			!QS!QQQQ"I
 	b!$A99T3g  	W *UVK	W  	Y"3,WXM	Y  	Y"3,WXM	Y.  "c!"sM   H3 I )I3  J 3III0/I03JJ	J(J##J(c                    	 t        |       }t        fd|D              }	 t        |d      }t        t        |d      |u S # t        $ r Y yw xY w# t        $ r Y yw xY w)zIf attr_name is implemented at builtin class, return True.

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

    Why this function needed? CPython implements int.__init__ by Descriptor
    but PyPy implements it by pure Python code.
    c              3  B   K   | ]  }t        |d i       v s|  yw)rN   Nr   )r:   c	attr_names     r&   r<   z*is_builtin_class_method.<locals>.<genexpr>  s!     RY,q*b2Q%Q1Rs   Fr   N)rL   nextStopIterationr=   r   r{   builtins)r%   r   mrort   ru   s    `   r&   is_builtin_class_methodr     so    SkRcRRC, 8T4(C//  
  s"   A A 	AA	AAc                  (    e Zd ZdZddZddZddZy)	DefaultValuezKA simple wrapper for default value of the parameters of overload functions.c                    || _         y r6   r   )selfr   s     r&   __init__zDefaultValue.__init__  s	    
r2   c                     | j                   |k(  S r6   r   r   others     r&   __eq__zDefaultValue.__eq__  s    zzU""r2   c                    | j                   S r6   r   r   s    r&   __repr__zDefaultValue.__repr__  s    zzr2   N)r   r9   r   None)r   rs   r   r   r   r9   )r   r]   r^   __doc__r   r   r   rK   r2   r&   r   r     s    U#r2   r   c                  8    e Zd ZdZddZd	dZd
dZddZddZy)TypeAliasForwardRefzPseudo typing class for autodoc_type_aliases.

    This avoids the error on evaluating the type inside `get_type_hints()`.
    c                    || _         y r6   ru   )r   ru   s     r&   r   zTypeAliasForwardRef.__init__  s	    	r2   c                     y r6   rK   r   s    r&   __call__zTypeAliasForwardRef.__call__  s    r2   c                     | j                   |k(  S r6   r  r   s     r&   r   zTypeAliasForwardRef.__eq__  s    yyE!!r2   c                ,    t        | j                        S r6   )hashru   r   s    r&   __hash__zTypeAliasForwardRef.__hash__  s    DIIr2   c                    | j                   S r6   r  r   s    r&   r   zTypeAliasForwardRef.__repr__  s    yyr2   N)ru   r9   r   r   )r   r   )r   r   r   r   )r   intr   )	r   r]   r^   r  r   r  r   r  r   rK   r2   r&   r  r    s     "r2   r  c                       e Zd ZdZddZddZy)TypeAliasModulez-Pseudo module class for autodoc_type_aliases.c                .    || _         || _        d | _        y r6   )_TypeAliasModule__modname_TypeAliasModule__mapping_TypeAliasModule__module)r   modnamemappings      r&   r   zTypeAliasModule.__init__  s      +/r2   c                   dj                  t        d | j                  |g            }|| j                  v rt	        | j                  |         S |dz   }| j                  j                         D ci c]  \  }}|j                  |      s|| }}}|rt        ||      S 	 t        |      S c c}}w # t        $ r? | j                  t        | j                        | _
        t        | j                  |      cY S w xY wNr   )r   filterr  r  r  r   
startswithr  r
   ImportErrorr  r{   )r   ru   fullnameprefixr   vnesteds          r&   __getattr__zTypeAliasModule.__getattr__  s    88F4$..$)?@At~~%&t~~h'?@@^F'+~~';';'=Vtq!fAUadVFV&x888(22 W # 8}},(5dnn(E"4==$778s   0B,
B,!
B2 2AC:9C:N)r  r9   r  dict[str, str]r   r   )ru   r9   r   r   )r   r]   r^   r  r   r  rK   r2   r&   r  r    s    708r2   r  c                       e Zd ZdZddZddZy)TypeAliasNamespacezPseudo namespace class for autodoc_type_aliases.

    This enables to look up nested modules and classes like `mod1.mod2.Class`.
    c                    || _         y r6   )_TypeAliasNamespace__mapping)r   r  s     r&   r   zTypeAliasNamespace.__init__   s	     r2   c                
   || j                   v rt        | j                   |         S |dz   }| j                   j                         D ci c]  \  }}|j                  |      s|| }}}|rt	        ||      S t
        c c}}w r  )r$  r  r   r  r  KeyError)r   r   r  r   r  r  s         r&   __getitem__zTypeAliasNamespace.__getitem__  sy    $.. &t~~c':;;3YF'+~~';';'=Vtq!fAUadVFV&sF33 Ws   	A?#A?N)r  r   r   r   )r   r9   r   r   )r   r]   r^   r  r   r'  rK   r2   r&   r"  r"    s    
!r2   r"  c                    t        |       }|j                  d      dk(  r#|j                  d      t        j                  k(  ryy)z<Check the function should be unwrapped on getting signature.r   
contextlib__file__TF)rH   rP   r)  r*  )subjectrG   s     r&   _should_unwrapr,    s:    W%K
#|3OOJ':+>+>>r2   Fc                B   |i }	 t        |       rt        j                  |       }nt        j                  | d      }t	        |j
                  j                               }|j                  }	 t        |      }t        j                  | d|      }t        |      D ]T  \  }}	|	j                  |v s||	j                     }
t        |
t              r|
j                  }
|	j                  |
      ||<   V d|v r(t        |d   t              r|d   j                  }n|d   }|r5t        j"                  |       rnt%        |      dkD  r|j'                  d       t        j(                  ||d      S # t        $ r t        j                  |       }Y Pw xY w# t         $ r Y w xY w)	z|Return a Signature object for the given *subject*.

    :param bound_method: Specify *subject* is a bound method or not
    NT)follow_wrapped
annotationr   r   F)return_annotation__validate_parameters__)r,  r!   	signaturer#   r>   
parametersvaluesr1  r"  r_   get_type_hints	enumerateru   r8   r  r   r   r   rQ   pop	Signature)r+  bound_methodtype_aliasesr3  r4  r1  localnsr   iparamr0  s              r&   r3  r3    s    /'"))'2I))'$GI i**1134J!33$\2++GT7C!*- 	EHAuzz[((4
j*=>!+J % D
1	E {"+h/1DE$/$9$>$>!$/$9! G$ :"q! Z;L5:< <Q  /%%g.	/*   	s+   8E- .AF 0A.F -FF	FFc                V  	 dd	d	fd}|i }||}t        | j                  j                               }t        |      D ];  \  }}|j                  s ||j                  ||      }|j                  |      ||<   = | j                  }|r
 ||||      }| j                  ||      S )z;Evaluate unresolved type annotations in a signature object.c                8    | j                  ||t                     S )zEvaluate a forward reference.)	_evaluater   )refglobalnsr<  s      r&   evaluate_forwardrefz/evaluate_signature.<locals>.evaluate_forwardrefZ  s    }}Xw	<<r2   c                   	 t        | t              rXt        | d      } |||      } t        | t              r |||      } | S t        | t              rt        | d      } |||      } | S # t        t        f$ r Y | S w xY w)z$Evaluate unresolved type annotation.T)r8   r9   r   	NameErrorrU   )r0  rC  r<  rB  rD  s       r&   evaluatez$evaluate_signature.<locals>.evaluate^  s    	*c* T20hH
j*5!4S(G!LJ   
C0$Z6C!4S(G!LJ
 	 9% 			s   A A- &A- -B ?B r/  )r4  r1  )rB  r   rC  rV   r<  rV   r   r   )r0  r   rC  rV   r<  rV   r   r   )r>   r4  r5  r7  r0  r   r1  )
sigrC  r<  rG  r4  r=  r>  r0  r1  rD  s
            @r&   evaluate_signaturerI  V  s    =& cnn++-.Jj) A5!%"2"2HgFJ!MMZM@JqMA
 --$%6'J;;*@Q;RRr2   c                b   |rd}nd}g }d}| j                   j                         D ]
  }|j                  |j                  k7  r ||j                  k(  r|j	                  d       |j                  |j
                  k(  r,||j                  |j                  dfv r|j	                  d       t               }|j                  |j                  k(  r|j                  d|j                  z          nS|j                  |j                  k(  r|j                  d|j                  z          n|j                  |j                         |rN|j                  |j                  ur6|j                  d       |j                  t        |j                  |             |j                  |j                  ura|r*|j                  |j                  ur|j                  d       n|j                  d	       |j                  t!        |j                               |j	                  |j#                                |j                  } |t$        j                  k(  r|j	                  d       d
j'                  |      }	| j(                  t$        j                  u s|du s|du rd|	 dS t        | j(                  |      }
d|	 d|
 S )aN  Stringify a 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)
    smartzfully-qualifiedN/*z**r   z = =r   Fr   r   z) -> )r4  r5  kindPOSITIONAL_ONLYappendKEYWORD_ONLYPOSITIONAL_OR_KEYWORDr   VAR_POSITIONALwriteru   VAR_KEYWORDr0  emptyr   defaultr   getvaluer   r   r1  )rH  show_annotationshow_return_annotationunqualified_typehintsmodeargs	last_kindr>  argconcatenated_argsr0  s              r&   stringify_signaturerb    s2     DI&&( ::...9@U@U3UKK::+++	e>Y>Y>C>S>S>B>D 1D KKj::---IIcEJJ&'ZZ5,,,IIdUZZ'(IIejj!u//u{{BIIdOII*5+;+;TBC==+5#3#35;;#F		% 		#II(78CLLN#JJ	;> I---C		$0u$"e+$%Q'')#*?*?F
$%U:,77r2   c                    d| z   dz   }t        j                  |      }t        t         j                  |j                  d         }t        ||      S )z&Create a Signature object from string.zdef funcz: passr   )astparser   FunctionDefbodysignature_from_ast)r3  codemodulefunctions       r&   signature_from_strrl    sC    	!H,DYYt_FCOOV[[^4Hh--r2   c           	     R   | j                   }t        |j                        }g }t        |d      r.t	        |j
                        }|t	        |j                         z   }nd}t	        |j                         }t        t	        |      |      D ]"  }|j                  dt        j                         $ t        |d      rt        |j
                        D ]  \  }}	||   t        j                  u rt        j                  }
nt        t        ||   |            }
t        |	j                  |      xs t        j                  }|j                  t        |	j                  t        j                   |
|              t        |j                         D ]  \  }}	|||z      t        j                  u rt        j                  }
nt        t        |||z      |            }
t        |	j                  |      xs t        j                  }|j                  t        |	j                  t        j"                  |
|              |j$                  rqt        |j$                  j                  |      xs t        j                  }|j                  t        |j$                  j                  t        j&                  |             t        |j(                        D ]  \  }}	|j*                  |   t        j                  }
n"t        t        |j*                  |   |            }
t        |	j                  |      xs t        j                  }|j                  t        |	j                  t        j,                  |
|              |j.                  rqt        |j.                  j                  |      xs t        j                  }|j                  t        |j.                  j                  t        j0                  |             t        | j2                  |      xs t        j                  }t5        j6                  ||      S )z*Create a Signature object from AST *node*.posonlyargsr   )rX  r0  r/  )r1  )r^  r>   defaultsr    rQ   rn  rangeinsertr   rW  r7  r   ast_unparser0  rQ  r`  rP  rS  varargrT  
kwonlyargskw_defaultsrR  kwargrV  returnsr!   r9  )noderi  r^  ro  paramsrn  positionals_r=  r`  rX  r0  r1  s                r&   rh  rh    s,   99DDMM"HFt]#$**+!C		N2$))n3x=+. ,9??+, t]# 0 01 		MFAs{ioo-#//&T24 %S^^T:MiooJMM)CGGY-F-F,3
L M		M DII& 
I3AO$	7ooG"HQ_5t<G !6I)//
i)H)H(/JH 	I
I {{ !7!7>Q)//
i1I1I+57 	8 DOO, 83A&ooG"D,,Q/68G 6I)//
i)?)?+57 	88 zz !6!6=P
i

	0E0E+57 	8 $DLL$7J9??V7HIIr2   c                z   t         fdd}|rg|ret        | ||      rXt        |      D ]J  }|j                  j	                  |      }|s!t        |d      s.t        |j                        }||rH|c S   ||       }t        |       r.|| j                  j                  k(  rt        | j                        S ||r|ri|rgt        |      D ]  }t        ||d      }| ||      }| n |9t        |      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
    c                <     || dd       }t        |t              r|S y )Nr  r7   )r%   
attrgetterdocs      r&   getdoc_internalzgetdoc.<locals>.getdoc_internal  s"    i.c3Jr2   r0   N)r%   r   r~  r   r   
str | None)r=   r.   rL   rN   rP   r    getdocr0   r+   r   r  r,   r!   )	r%   r~  allow_inheritedrt   ru   r  rw   rx   r  s	            r&   r  r  
  sD    :F  tc35c{ 	G##''-Dj1"("7?/J	 #
C~#!6!66chh	4!#; #GT48#)$/C {%c{ "G't<D'%nnT2?!" ;..%CJr2   )r%   r   r   r   )r%   r   r(   zCallable | Noner   r   )r%   r   r   zSequence[str] | None)r%   r   r   zMapping[str, Any])r%   r   r   ztuple[type, ...])r%   r   r   ztuple[Any, ...] | None)r%   r   r   zdict[str, Any] | Noner   )ri   r   r   r   )NN)r%   r   rt   r   ru   r  r   r   )r   r   r   r   )r%   r   ru   r9   r   r   r   r   )r%   r   r   r   r   r9   )r%   r   r   r9   r   r   )r+  r   r   r   )FN)r+  r   r:  r   r;  dict | Noner   inspect.Signature)rH  r  rC  r  r<  r  r   r  )TTF)
rH  r  rZ  r   r[  r   r\  r   r   r9   )r3  r9   r   r  )r   )rx  zast.FunctionDefri  r9   r   r  )r%   r   r~  r   r  r   rt   r   ru   r  r   r  )ar  
__future__r   rd  r   r)  rf   r!   rer`   r   r_   collections.abcr   r   r   r   r   r   r	   	importlibr
   r   r   r   r   r   r   ior   r   r   r   r   r   r   r   r   sphinx.pycode.astr   rr  sphinx.utilr   sphinx.util.typingr   r   	getLoggerr   loggercompile
IGNORECASEr   r"   r1   rA   rE   rH   rL   rR   rX   rc   rj   rl   rn   r+   r.   r/   r   r   r   r   r   r   r   r   r   r-   r   r   r   r=   r   r   r   r   r  r  rV   r9   r"  r,  r3  rI  rb  rl  rh  r  rK   r2   r&   <module>r     s   , " 
     	 
   - S S #    ' & 4  ?			8	$BJJ;R]]K 	 59 $.R;
$
5
 D
>
:41
.
-
-
,8
=,, 8A{ ? D0.
 
 ,8 8Bc3h .7<$7<t HL.2*S +*S-*SZ IM7;6;;804;8/3;8@C;8|.=JD (!7	77 7 
	7
 7 7r2   