a �DOg��� @s�dZdZddlZddlZddlZddlZddlZddlZ ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZmZe�Zej��D]\ZZeede<q�dZdd �Z d d �Z!d d �Z"dd�Z#dd�Z$e%ed��rdd�Z&ndd�Z&e%ed��r2dd�Z'ndd�Z'dd�Z(dd�Z)dd�Z*d d!�Z+d"d#�Z,d$d%�Z-d&d'�Z.d(d)�Z/d*d+�Z0d,d-�Z1d.d/�Z2d0d1�Z3d2d3�Z4d4d5�Z5d6d7�Z6d�d8d9�Z7ed:d;�Z8dd?�Z:dd@�dAdB�Z;dCdD�ZdIdJ�Z?dKdL�Z@dMdN�ZAdOdP�ZBdQdR�ZCd�dSdT�ZDiZEiZFd�dUdV�ZGGdWdX�dXeH�ZIGdYdZ�dZejJ�ZKd[d\�ZLd]d^�ZMGd_d`�d`eH�ZNGdadb�db�ZOdcdd�ZPdedf�ZQdgdh�ZRdidj�ZSd�dldm�ZTedndo�ZUdpdq�ZVedrds�ZWdtdu�ZXedvdw�ZYdxdy�ZZedzd{�Z[d|d}�Z\d�d~d�Z]d�d��Z^dddd�iie_d�d��d�d��d�d��d�d��e]f d�d��Z`e_d�d��d�d��d�d��fd�d��Zad�d��Zbd�d��Zcd�d��Zded�d��Zed�d��Zfed�d��Zgd�d�d��Zhd�d��Zied�d�egjj�Zkd�d�d��Zld�d�d��Zmd�d��Zn�dd�d��Zo�dd�d��Zpeq�Zrd�d��Zsd�d��Ztd�d��Zud�d��Zvd�d��Zwerfd�d��Zxd�Zyd�Zzd�Z{d�Z|d�d��Z}d�d��Z~d�Zd�Z�d�Z�d�Z�d�dńZ�d�dDŽZ�e�e�j��Z�e�e�j��Z�e�e�j�d��Z�e�e�e�ej�fZ�d�dʄZ��dd�d̄Z�d�d΄Z�d�dЄZ�d�d҄Z�d�dԄZ�d�dքZ��dd�dلZ��dd�dۄZ��dd�d݄Z�d�d�dޜd�d��Z�Gd�d�d�Z�Gd�d�d�Z�Gd�d�d�ej��Z�e�j�Z�e�j�Z�e�j�Z�e�j�Z�e�j�Z�e�d�e�d�e�d�e�d�e�d�iZ�Gd�d�d�Z�Gd�d�d�Z�Gd�d�d�Z�d�d�d�d�Z�d�d��Z�e�d�k�r�e��dS(aGet useful information from live Python objects. This module encapsulates the interface provided by the internal special attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion. It also provides some help for examining source code and class layout. Here are some of the useful functions provided by this module: ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(), isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(), isroutine() - check object types getmembers() - get members of an object that satisfy a given condition getfile(), getsourcefile(), getsource() - find an object's source code getdoc(), getcomments() - get documentation on an object getmodule() - determine the module that an object came from getclasstree() - arrange classes so as to represent their hierarchy getargvalues(), getcallargs() - get info about function arguments getfullargspec() - same, with support for Python 3 features formatargvalues() - format an argument spec getouterframes(), getinnerframes() - get info about frames currentframe() - get the current stack frame stack(), trace() - get info about frames on the stack or in a traceback signature() - get a Signature object for the callable )zKa-Ping Yee z'Yury Selivanov �N)� attrgetter)� namedtuple� OrderedDictZCO_icCs t|tj�S)z�Return true if the object is a module. Module objects provide these attributes: __cached__ pathname to byte compiled file __doc__ documentation string __file__ filename (missing for built-in modules))� isinstance�types� ModuleType��object�r �/usr/lib64/python3.9/inspect.py�ismodule@sr cCs t|t�S)z�Return true if the object is a class. Class objects provide these attributes: __doc__ documentation string __module__ name of module in which this class was defined)r�typerr r r �isclassIsrcCs t|tj�S)a_Return true if the object is an instance method. Instance method objects provide these attributes: __doc__ documentation string __name__ name with which this method was defined __func__ function object containing implementation of method __self__ instance to which this method is bound)rr� MethodTyperr r r �ismethodQsrcCs:t|�st|�st|�rdSt|�}t|d�o8t|d� S)a�Return true if the object is a method descriptor. But not if ismethod() or isclass() or isfunction() are true. This is new in Python 2.2, and, for example, is true of int.__add__. An object passing this test has a __get__ attribute but not a __set__ attribute, but beyond that the set of attributes varies. __name__ is usually sensible, and __doc__ often is. Methods implemented via descriptors that also pass one of the other tests return false from the ismethoddescriptor() test, simply because the other tests promise more -- you can, e.g., count on having the __func__ attribute (etc) when an object passes ismethod().F�__get__�__set__�rr� isfunctionr �hasattr�r �tpr r r �ismethoddescriptor[srcCs8t|�st|�st|�rdSt|�}t|d�p6t|d�S)a}Return true if the object is a data descriptor. Data descriptors have a __set__ or a __delete__ attribute. Examples are properties (defined in Python) and getsets and members (defined in C). Typically, data descriptors will also have __name__ and __doc__ attributes (properties, getsets, and members have both of these attributes), but this is not guaranteed.Fr� __delete__rrr r r �isdatadescriptorosr�MemberDescriptorTypecCs t|tj�S)��Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.)rrrrr r r �ismemberdescriptorsrcCsdS)rFr rr r r r�s�GetSetDescriptorTypecCs t|tj�S)��Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.)rrrrr r r �isgetsetdescriptor�sr cCsdS)rFr rr r r r �scCs t|tj�S)a(Return true if the object is a user-defined function. Function objects provide these attributes: __doc__ documentation string __name__ name with which this function was defined __code__ code object containing compiled function bytecode __defaults__ tuple of any default values for arguments __globals__ global namespace in which this function was defined __annotations__ dict of parameter annotations __kwdefaults__ dict of keyword only parameters with defaults)rr� FunctionTyperr r r r�s rcCs6t|�r|j}qt�|�}t|�s&dSt|jj|@�S)z�Return true if ``f`` is a function (or a method or functools.partial wrapper wrapping a function) whose code object has the given ``flag`` set in its flags.F)r�__func__� functools�_unwrap_partialr�bool�__code__�co_flags)�f�flagr r r �_has_code_flag�s  r*cCs t|t�S)z�Return true if the object is a user-defined generator function. Generator function objects provide the same attributes as functions. See help(isfunction) for a list of attributes.)r*Z CO_GENERATOR��objr r r �isgeneratorfunction�sr-cCs t|t�S)zuReturn true if the object is a coroutine function. Coroutine functions are defined with "async def" syntax. )r*Z CO_COROUTINEr+r r r �iscoroutinefunction�sr.cCs t|t�S)z�Return true if the object is an asynchronous generator function. Asynchronous generator functions are defined with "async def" syntax and have "yield" expressions in their body. )r*ZCO_ASYNC_GENERATORr+r r r �isasyncgenfunction�sr/cCs t|tj�S)z7Return true if the object is an asynchronous generator.)rr�AsyncGeneratorTyperr r r � isasyncgen�sr1cCs t|tj�S)aReturn true if the object is a generator. Generator objects provide these attributes: __iter__ defined to support iteration over container close raises a new GeneratorExit exception inside the generator to terminate the iteration gi_code code object gi_frame frame object or possibly None once the generator has been exhausted gi_running set to 1 when generator is executing, 0 otherwise next return the next item from the container send resumes the generator and "sends" a value that becomes the result of the current yield-expression throw used to raise an exception inside the generator)rr� GeneratorTyperr r r � isgenerator�sr3cCs t|tj�S)z)Return true if the object is a coroutine.)rr� CoroutineTyperr r r � iscoroutine�sr5cCs6t|tj�p4t|tj�r(t|jjt@�p4t|tj j �S)z?Return true if object can be passed to an ``await`` expression.) rrr4r2r%�gi_coder'ZCO_ITERABLE_COROUTINE� collections�abc� Awaitablerr r r � isawaitable�s   � �r:cCs t|tj�S)abReturn true if the object is a traceback. Traceback objects provide these attributes: tb_frame frame object at this level tb_lasti index of last attempted instruction in bytecode tb_lineno current line number in Python source code tb_next next inner traceback object (called by this level))rr� TracebackTyperr r r � istraceback�sr<cCs t|tj�S)a`Return true if the object is a frame object. Frame objects provide these attributes: f_back next outer frame object (this frame's caller) f_builtins built-in namespace seen by this frame f_code code object being executed in this frame f_globals global namespace seen by this frame f_lasti index of last attempted instruction in bytecode f_lineno current line number in Python source code f_locals local namespace seen by this frame f_trace tracing function for this frame, or None)rr� FrameTyperr r r �isframe�s r>cCs t|tj�S)a�Return true if the object is a code object. Code objects provide these attributes: co_argcount number of arguments (not including *, ** args or keyword only arguments) co_code string of raw compiled bytecode co_cellvars tuple of names of cell variables co_consts tuple of constants used in the bytecode co_filename name of file in which this code object was created co_firstlineno number of first line in Python source code co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg | 16=nested | 32=generator | 64=nofree | 128=coroutine | 256=iterable_coroutine | 512=async_generator co_freevars tuple of names of free variables co_posonlyargcount number of positional only arguments co_kwonlyargcount number of keyword only arguments (not including ** arg) co_lnotab encoded mapping of line numbers to bytecode indices co_name name with which this code object was defined co_names tuple of names other than arguments and function locals co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables)rr�CodeTyperr r r �iscodesr@cCs t|tj�S)a,Return true if the object is a built-in function or method. Built-in functions and methods provide these attributes: __doc__ documentation string __name__ original name of this function or method __self__ instance to which a method is bound, or None)rr�BuiltinFunctionTyperr r r � isbuiltinsrBcCs t|�pt|�pt|�pt|�S)zdS|j� �D]\}}t |dd�rHdSqH|j D]6}t |dd�D]$}t ||d�}t |dd�rzdSqzqjdS)z:Return true if the object is an abstract base class (ABC).FT�__abstractmethods__�__isabstractmethod__r N) rr � __flags__�TPFLAGS_IS_ABSTRACT� issubclassr8�ABCMetar�__dict__�items�getattr� __bases__)r �name�value�baser r r � isabstract.s"        rQc Cst|�r|ft|�}nd}g}t�}t|�}z:|jD].}|j��D]\}}t|tj �rD|� |�qDq6Wnt yzYn0|D]|} zt || �} | |vr�t �Wn8t y�|D]}| |jvr�|j| } q�q�Yq�Yn0|r�|| �r�|� | | f�|� | �q�|jdd�d�|S)z�Return all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.r cSs|dS)Nrr )Zpairr r r �o�zgetmembers..��key)r�getmro�set�dirrMrJrKrr�DynamicClassAttribute�append�AttributeErrorrL�add�sort) r � predicate�mro�results� processed�namesrP�k�vrUrOr r r � getmembersFs:          re� Attributezname kind defining_class objectc CsTt|�}tt|��}tdd�|D��}|f|}||}t|�}|D].}|j��D]\}}t|tj�rR|� |�qRqDg} t �} |D�]�} d} d} d}| | v�rzz| dkr�t d��t || �} Wn$t y�}z WYd}~n�d}~00t | d| �} | |v�rzd} d}|D] }t || d�}|| u�r|}�q|D]@}z|� || �}Wnt�yXY�q*Yn0|| u�r*|}�q*|du�rz|} |D]0}| |jv�r~|j| }| |v�r�|} �q��q~| du�r�q�| du�r�| n|}t|ttjf��r�d}|}nFt|ttjf��rd}|}n*t|t��rd }|}nt|��r,d }nd }| � t| || |��| �| �q�| S) aNReturn list of attribute-descriptor tuples. For each name in dir(cls), the return list contains a 4-tuple with these elements: 0. The name (a string). 1. The kind of attribute this is, one of these strings: 'class method' created via classmethod() 'static method' created via staticmethod() 'property' created via property() 'method' any other flavor of method or descriptor 'data' not a method 2. The class which defined this attribute (a class). 3. The object as obtained by calling getattr; if this fails, or if the resulting object does not live anywhere in the class' mro (including metaclasses) then the object is looked up in the defining class's dict (found by walking the mro). If one of the items in dir(cls) is stored in the metaclass it will now be discovered and not have None be listed as the class in which it was defined. Any items whose home class cannot be discovered are skipped. css|]}|ttfvr|VqdS�N)r r )�.0�clsr r r � �rSz'classify_class_attrs..NrJz)__dict__ is special, don't want the proxy� __objclass__z static methodz class method�property�method�data)rVr �tuplerXrJrKrrrYrZrW� ExceptionrL� __getattr__r[� staticmethod�BuiltinMethodType� classmethod�ClassMethodDescriptorTyperlrCrfr\)rir_ZmetamroZ class_basesZ all_basesrbrPrcrd�resultrarNZhomeclsZget_objZdict_obj�excZlast_clsZsrch_clsZsrch_objr,�kindr r r �classify_class_attrsts�                    rycCs|jS)zHReturn tuple of base classes (including cls) in method resolution order.)�__mro__)rir r r rV�srV��stopcs|�durdd�}n �fdd�}|}t|�|i}t��}||�rx|j}t|�}||vs`t|�|krntd�|���|||<q6|S)anGet the object wrapped by *func*. Follows the chain of :attr:`__wrapped__` attributes returning the last object in the chain. *stop* is an optional callback accepting an object in the wrapper chain as its sole argument that allows the unwrapping to be terminated early if the callback returns a true value. If the callback never returns a true value, the last object in the chain is returned as usual. For example, :func:`signature` uses this to stop unwrapping if any object in the chain has a ``__signature__`` attribute defined. :exc:`ValueError` is raised if a cycle is encountered. NcSs t|d�S�N� __wrapped__�r�r(r r r � _is_wrapper�szunwrap.._is_wrappercst|d�o�|� Sr}rr�r{r r r�sz!wrapper loop when unwrapping {!r})�id�sys�getrecursionlimitr~�len� ValueError�format)�funcr|r�r(�memoZrecursion_limitZid_funcr r{r �unwrap�s    r�cCs|��}t|�t|���S)zBReturn the indent size, in spaces, at the start of a line of text.)� expandtabsr��lstrip)�lineZexpliner r r � indentsizesr�cCsNtj�|j�}|durdS|j�d�dd�D]}t||�}q.t|�sJdS|S)N�.�����)r��modules�get� __module__� __qualname__�splitrLr)r�rirNr r r � _findclasss r�c Cs t|�rR|jD]>}|turz |j}Wnty:YqYn0|dur|SqdSt|�r�|jj}|j}t|�r�t t ||d�d�|jur�|}n|j }�n$t |�r�|j}t |�}|dus�t ||�|ur�dSn�t |��r|j}|j}t|��r|jd||jk�r|}n|j }n�t|t��rN|j}|j}t |�}|du�sHt ||�|u�r�dSnnt|��sbt|��r�|j}|j}t ||�|u�r�dSt|��r�t |dd�}t|t��r�||v�r�||SndS|jD]D}zt ||�j}Wnt�y�Y�q�Yn0|du�r�|S�q�dS)Nr"r�� __slots__)rrzr �__doc__r[rr"�__name__�__self__rL� __class__rr�rBr�rrl�fgetrrrkr�dict)r,rP�docrN�selfrir��slotsr r r �_finddoc!sn     �   �        r�c Csdz |j}WntyYdS0|durNz t|�}WnttfyLYdS0t|t�s\dSt|�S)z�Get the documentation string for an object. All tabs are expanded to spaces. To clean up docstrings that are indented to line up with blocks of code, any whitespace than can be uniformly removed from the second line onwards is removed.N)r�r[r�� TypeErrorr�str�cleandoc)r r�r r r �getdoc_s    r�cCs�z|���d�}Wnty&YdS0tj}|dd�D]*}t|���}|r:t|�|}t||�}q:|rz|d��|d<|tjkr�tdt|��D]}|||d�||<q�|r�|ds�|� �q�|r�|ds�|� d�q�d� |�SdS)z�Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed.� N�rr�) r�r�� UnicodeErrorr��maxsizer�r��min�range�pop�join)r��linesZmarginr�Zcontent�indent�ir r r r�rs&     (    r�cCs�t|�r(t|dd�r|jStd�|���t|�rht|d�rZtj� |j �}t|dd�rZ|jStd�|���t |�rv|j }t |�r�|j}t|�r�|j}t|�r�|j}t|�r�|jStd�t|�j���dS)z@Work out which source or compiled file an object was defined in.�__file__Nz{!r} is a built-in moduler�z{!r} is a built-in classzVmodule, class, method, function, traceback, frame, or code object was expected, got {})r rLr�r�r�rrr�r�r�r�rr"rr&r<�tb_framer>�f_coder@� co_filenamer r�)r �moduler r r �getfile�s.   �r�cCsTtj�|�}dd�tj��D�}|��|D]"\}}|�|�r,|d|�Sq,dS)z1Return the module name for a given file, or None.cSsg|]}t|� |f�qSr )r�)rh�suffixr r r � �s�z!getmodulename..N)�os�path�basename� importlib� machinery� all_suffixesr]�endswith)r��fname�suffixesZneglenr�r r r � getmodulename�s �  r�cs�t|��tjjdd�}|tjjdd�7}t�fdd�|D��r`tj���dtjj d�nt�fdd�tjj D��r~dStj� ��r��St t |��dd�dur��S�tjvr��SdS)z�Return the filename that can be used to locate an object's source. Return None if no way can be identified to get the source. Nc3s|]}��|�VqdSrg�r��rh�s��filenamer r rj�rSz getsourcefile..rc3s|]}��|�VqdSrgr�r�r�r r rj�rS� __loader__)r�r�r��DEBUG_BYTECODE_SUFFIXES�OPTIMIZED_BYTECODE_SUFFIXES�anyr�r��splitext�SOURCE_SUFFIXES�EXTENSION_SUFFIXES�existsrL� getmodule� linecache�cache)r Zall_bytecode_suffixesr r�r � getsourcefile�s" � �  r�cCs,|durt|�pt|�}tj�tj�|��S)z�Return an absolute path to the source or compiled file for an object. The idea is for each object to have a unique origin, so this routine normalizes the result as much as possible.N)r�r�r�r��normcase�abspath)r � _filenamer r r � getabsfile�sr�c Cs�t|�r |St|d�r$tj�|j�S|durD|tvrDtj�t|�Szt||�}Wntt fyjYdS0|tvr�tj�t|�Stj� �� �D]\\}}t|�r�t|d�r�|j }|t �|d�kr�q�|t |<t|�}|jt|<ttj�|�<q�|tv�r tj�t|�Stjd}t|d��s$dSt||j��rLt||j�}||u�rL|Stjd}t||j��r~t||j�} | |u�r~|SdS)zAReturn the module an object was defined in, or None if not found.r�Nr��__main__r��builtins)r rr�r�r�r�� modulesbyfiler�r��FileNotFoundError�copyrKr��_filesbymodnamer�r�r��realpathrL) r r��file�modnamer�r(�mainZ mainobjectZbuiltinZ builtinobjectr r r r��sJ �  �        r�c@s eZdZdS)�ClassFoundExceptionN�r�r�r�r r r r r�sr�c@s(eZdZdd�Zdd�ZeZdd�ZdS)� _ClassFindercCsg|_||_dSrg)�stack�qualname)r�r�r r r �__init__ sz_ClassFinder.__init__cCs<|j�|j�|j�d�|�|�|j��|j��dS)Nz)r�rZrN� generic_visitr��r��noder r r �visit_FunctionDefs    z_ClassFinder.visit_FunctionDefcCsb|j�|j�|jd�|j�krJ|jr4|jdj}n|j}|d8}t|��|�|�|j� �dS)Nr�rr�) r�rZrNr�r��decorator_list�linenor�r�r�)r�r�� line_numberr r r �visit_ClassDefs z_ClassFinder.visit_ClassDefN)r�r�r�r�r�Zvisit_AsyncFunctionDefr�r r r r r� sr�c Cs�t|�}|rt�|�n$t|�}|�d�r4|�d�szsource code not availablezcould not get source coder�Nzcould not find class definition�co_firstlinenoz"could not find function definitionr�z>^(\s*def\s)|(\s*async\s+def\s)|(.*(?r�r@rr��re�compile� IndexError�match) r r�r�r�r��sourceZtreeZ class_finder�er��lnum�patr�r r r � findsource)s`                   rc Cs,zt|�\}}Wnttfy(YdS0t|�r�d}|rR|ddd�dkrRd}|t|�krx||��dvrx|d}qR|t|�kr�||dd�dkr�g}|}|t|�kr�||dd�dkr�|�||���|d}q�d�|�S�n>|dk�r(t ||�}|d}|dk�r(||� �dd�dk�r(t ||�|k�r(||��� �g}|dk�r�|d}||��� �}|dd�dk�r�t ||�|k�r�|g|dd�<|d}|dk�r��q�||��� �}�qr|�r�|d��dk�r�g|dd�<�q�|�r|d ��dk�rg|d d�<�q�d�|�SdS) zwGet lines of comments immediately preceding an object's source code. Returns None when source can't be found. Nr�z#!r�)r��#rr�r�) rr�r�r r��striprZr�r�r�r�)r r�r�startZcomments�endr�Zcommentr r r � getcommentsmsH      $� $r c@s eZdZdS)� EndOfBlockNr�r r r r r �rSr c@s eZdZdZdd�Zdd�ZdS)� BlockFinderz@Provide a tokeneater() method to detect the end of a code block.cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrFr�)r��islambda�started�passline� indecorator�decoratorhasargs�last� body_col0�r�r r r r��szBlockFinder.__init__cCsr|jsB|jsB|dkrd|_n|dvr8|dkr2d|_d|_d|_�n,|dkrZ|jrVd|_�n|dkrv|jrtd|_d|_n�|tjkr�d|_|d|_|jr�t�|jr�|js�d|_n�|jr�n�|tj kr�|j dur�|jr�|d |_ |j d |_ d|_n�|tj k�r|j d |_ |j dk�rnt�nV|tj k�rL|j du�rn|d |j k�rn|d|_n"|j dk�rn|tj tjfv�rnt�dS) N�@T)�def�class�lambdar�(�)Frr�)rrr rr�tokenize�NEWLINErr �INDENTrr��DEDENT�COMMENT�NL)r�r �tokenZsrowcolZerowcolr�r r r � tokeneater�sL              zBlockFinder.tokeneaterN)r�r�r�r�r�r"r r r r r �s r c CsTt�}z(t�t|�j�}|D]}|j|�qWnttfyDYn0|d|j�S)z@Extract the block of code at the top of the given list of lines.N) r r�generate_tokens�iter�__next__r"r �IndentationErrorr)r�Z blockfinder�tokensZ_tokenr r r �getblock�sr(cCsbt|�}t|�\}}t|�r"|j}t|�s>t|�rF|jjdkrF|dfSt||d��|dfSdS)a�Return a list of source lines and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of the lines corresponding to the object and the line number indicates where in the original source file the first line of code was found. An OSError is raised if the source code cannot be retrieved.zrNr�) r�rr<r�r r>r��co_namer(�r r�rr r r �getsourcelines�s � �r+cCst|�\}}d�|�S)aReturn the text of the source code for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a single string. An OSError is raised if the source code cannot be retrieved.r�)r+r�r*r r r � getsource�s r,cCsRg}|jtdd�d�|D]2}|�||jf�||vr|�t||||��q|S)z-Recursive helper function for getclasstree().r�r�rT)r]rrZrM�walktree)�classes�children�parentr`�cr r r r-sr-FcCs�i}g}|D]d}|jr^|jD]>}||vr0g||<|||vrJ||�|�|r||vrqpqq ||vr |�|�q |D]}||vrv|�|�qvt||d�S)a�Arrange the given list of classes into a hierarchy of nested lists. Where a nested list appears, it contains classes derived from the class whose entry immediately precedes the list. Each entry is a 2-tuple containing a class and a tuple of its base classes. If the 'unique' argument is true, exactly one entry appears in the returned structure for each class in the given list. Otherwise, classes using multiple inheritance and their descendants will appear multiple times.N)rMrZr-)r.�uniquer/�rootsr1r0r r r � getclasstrees     r4� Argumentszargs, varargs, varkwc Cs�t|�std�|���|j}|j}|j}t|d|��}t||||��}d}||7}d}|jt@rx|j|}|d}d}|jt @r�|j|}t ||||�S)aGet information about the arguments accepted by a code object. Three things are returned: (args, varargs, varkw), where 'args' is the list of argument names. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None.z{!r} is not a code objectNrr�) r@r�r�� co_varnames� co_argcount�co_kwonlyargcount�listr'� CO_VARARGS�CO_VARKEYWORDSr5) �corb�nargsZnkwargsr�� kwonlyargs�step�varargs�varkwr r r �getargs+s"    rB�ArgSpeczargs varargs keywords defaultscCsDtjdtdd�t|�\}}}}}}}|s.|r6td��t||||�S)aeGet the names and default values of a function's parameters. A tuple of four things is returned: (args, varargs, keywords, defaults). 'args' is a list of the argument names, including keyword-only argument names. 'varargs' and 'keywords' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. This function is deprecated, as it does not support annotations or keyword-only parameters and will raise ValueError if either is present on the supplied callable. For a more structured introspection API, use inspect.signature() instead. Alternatively, use getfullargspec() for an API with a similar namedtuple based interface, but full support for annotations and keyword-only parameters. Deprecated since Python 3.5, use `inspect.getfullargspec()`. zhinspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()r�� stacklevelzgFunction has keyword-only parameters or annotations, use inspect.signature() API which can support them)�warnings�warn�DeprecationWarning�getfullargspecr�rC)r�r�r@rA�defaultsr>�kwonlydefaults�annr r r � getargspecHs��rM� FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc Cszzt|ddtd�}Wn.tyB}ztd�|�WYd}~n d}~00g}d}d}g}g}i}d} i} |j|jurz|j|d<|j��D]�} | j} | j } | t ur�|� | �| j | jur�| | j f7} nv| t ur�|� | �| j | jur�| | j f7} nJ| tur�| }n<| tu�r(|� | �| j | ju�r6| j | | <n| tu�r6| }| j| jur�| j|| <q�| �sXd} | �sbd} t||||| || |�S)a$Get the names and default values of a callable object's parameters. A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. 'kwonlyargs' is a list of keyword-only parameter names. 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. 'annotations' is a dictionary mapping parameter names to annotations. Notable differences from inspect.signature(): - the "self" parameter is always reported, even for bound methods - wrapper chains defined by __wrapped__ *not* unwrapped automatically F��follow_wrapper_chains�skip_bound_arg�sigclszunsupported callableNr �return)�_signature_from_callable� Signaturerpr��return_annotation�empty� parameters�valuesrxrN�_POSITIONAL_ONLYrZ�default�_POSITIONAL_OR_KEYWORD�_VAR_POSITIONAL� _KEYWORD_ONLY� _VAR_KEYWORD� annotationrN)r��sig�exr�r@rA� posonlyargsr>� annotationsrJ� kwdefaults�paramrxrNr r r rIis\�              �rI�ArgInfozargs varargs keywords localscCs t|j�\}}}t||||j�S)a9Get information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names. 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given frame.)rBr�rg�f_locals)�framer�r@rAr r r � getargvalues�srjcCsjt|dd�dkr t|��dd�St|tj�r4t|�St|t�rb|jd|fvrR|j S|jd|j St|�S)Nr��typingztyping.r�r�r�) rL�repr�replacerr� GenericAliasr�r r�r�)r`Z base_moduler r r �formatannotation�s  rocst|dd���fdd�}|S)Nr�cs t|��Srg)ro)r`�r�r r �_formatannotation�sz5formatannotationrelativeto.._formatannotation)rL)r rqr rpr �formatannotationrelativeto�s  rrr cCsd|S�N�*r �rNr r r rR�rSrRcCsd|S�N�**r rur r r rR�rScCs dt|�S�N�=�rl�rOr r r rR�rScCsd|S)Nz -> r )�textr r r rR�rSc s<ddlm} | dtdd����fdd�}g}|rBt|�t|�}t|�D]:\}}||�}|rz||krz|| |||�}|�|�qJ|dur�|�|||���n|r�|�d �|r�|D]2}||�}|r�||vr�|| ||�7}|�|�q�|du�r|�| ||���d d �|�d }d �v�r8|| ��d ��7}|S)a�Format an argument spec from the values returned by getfullargspec. The first seven arguments are (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). The other five arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The last argument is an optional function to format the sequence of arguments. Deprecated since Python 3.5: use the `signature` function and `Signature` objects. r)rGzc`formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directlyrrDcs(�|�}|�vr$|d��|�7}|S)Nz: r )�argrv�rdro� formatargr r �formatargandannotation�sz-formatargspec..formatargandannotationNrtr�, rrS)rFrGrHr�� enumeraterZr�)r�r@rArJr>rKrdr� formatvarargs� formatvarkw� formatvalueZ formatreturnsrorGr��specsZ firstdefaultr�r}�specZ kwonlyargrvr r~r � formatargspec�s< �       r�cCsd|Srsr rur r r rRrScCsd|Srvr rur r r rRrScCs dt|�Srxrzr{r r r rR rSc Cs�|||fdd�}g} tt|��D]} | �||| ��q |rV| �||�|||��|rt| �||�|||��dd�| �dS)afFormat an argument spec from the 4 values returned by getargvalues. The first four arguments are (args, varargs, varkw, locals). The next four arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The ninth argument is an optional function to format the sequence of arguments.cSs||�|||�Srgr )rN�localsrr�r r r �convert'sz formatargvalues..convertrr�r)r�r�rZr�) r�r@rAr�rr�r�r�r�r�r�r r r �formatargvaluess � r�cs��fdd�|D�}t|�}|dkr,|d}n>|dkr@dj|�}n*dj|dd��}|dd�=d �|�|}td |||rzd nd |dkr�d nd|f��dS)Ncsg|]}|�vrt|��qSr rz)rhrN�rYr r r�4rSz&_missing_arguments..r�rrz {} and {}z , {} and {}�����r�z*%s() missing %i required %s argument%s: %s� positional� keyword-onlyr�r�)r�r�r�r�)�f_nameZargnames�posrYrb�missingr��tailr r�r �_missing_arguments3s    ��r�c s�t|�|}t�fdd�|D��}|r:|dk} d|f} n2|rTd} d|t|�f} nt|�dk} tt|��} d} |r�d} | |dkr�d nd||dkr�d ndf} td || | r�d nd|| |dkr�|s�d nd f��dS) Ncsg|]}|�vr|�qSr r )rhr}r�r r r�ErSz_too_many..r�z at least %dTz from %d to %dr�z7 positional argument%s (and %d keyword-only argument%s)r�z5%s() takes %s positional argument%s but %d%s %s givenZwasZwere)r�r�r�) r�r�Zkwonlyr@ZdefcountZgivenrYZatleastZ kwonly_given�pluralraZ kwonly_sig�msgr r�r � _too_manyCs*    ���r�cOst|�}|\}}}}}} } |j} i} t|�rB|jdurB|jf|}t|�} t|�}|r^t|�nd}t| |�}t|�D]}||| ||<qt|r�t||d��| |<t||�}|r�i| |<|� �D]T\}}||vr�|s�t d| |f��|| ||<q�|| v�rt d| |f��|| |<q�| |k�r<|�srKrLr�Z arg2valueZnum_posZnum_argsZ num_defaults�nr�Zpossible_kwargs�kwrOZreqr}r��kwargr r r � getcallargsXsf    �  �  �     r�� ClosureVarsz"nonlocals globals builtins unboundc Cs�t|�r|j}t|�s$td�|���|j}|jdur:i}ndd�t|j|j�D�}|j }|� dt j �}t |�rt|j }i}i}t�}|jD]`}|dvr�q�z||||<Wq�ty�z||||<Wnty�|�|�Yn0Yq�0q�t||||�S)a Get the mapping of free variables to their current values. Returns a named tuple of dicts mapping the current nonlocal, global and builtin references as seen by the body of the function. A final set of unbound names that could not be resolved is also provided. �{!r} is not a Python functionNcSsi|]\}}||j�qSr )� cell_contents)rh�varZcellr r r � �s�z"getclosurevars..� __builtins__)�None�True�False)rr"rr�r�r&� __closure__�zip� co_freevars� __globals__r�r�rJr rW�co_names�KeyErrorr\r�) r��codeZ nonlocal_varsZ global_nsZ builtin_nsZ global_varsZ builtin_varsZ unbound_namesrNr r r �getclosurevars�s<   �   �r�� Tracebackz+filename lineno function code_context indexr�cCs�t|�r|j}|j}n|j}t|�s2td�|���t|�p@t|�}|dkr�|d|d}zt |�\}}Wnt y�d}}Yq�0t dt |t |�|��}||||�}|d|}nd}}t|||jj||�S)a�Get information about a frame or traceback object. A tuple of five things is returned: the filename, the line number of the current line, the function name, a list of lines of context from the source code, and the index of the current line within that list. The optional second argument specifies the number of lines of context to return, which are centered around the current line.z'{!r} is not a frame or traceback objectrr�rN)r<� tb_linenor��f_linenor>r�r�r�r�rr��maxr�r�r�r�r))ri�contextr�r�rr�r�indexr r r � getframeinfo�s$ r�cCs|jS)zCGet the line number from a frame object, allowing for optimization.)r��rir r r � getlineno�sr�� FrameInfor�cCs2g}|r.|ft||�}|�t|��|j}q|S)z�Get a list of records for a frame and all higher (calling) frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.)r�rZr��f_back)rir�� framelist� frameinfor r r �getouterframes�s r�cCs4g}|r0|jft||�}|�t|��|j}q|S)z�Get a list of records for a traceback's frame and all lower frames. Each record contains a frame object, filename, line number, function name, a list of lines of context, and index within the context.)r�r�rZr��tb_next)�tbr�r�r�r r r �getinnerframess r�cCsttd�rt�d�SdS)z?Return the frame of the caller or None if this is not possible.� _getframer�N)rr�r�r r r r � currentframe sr�cCstt�d�|�S)z@Return a list of records for the stack above the caller's frame.r�)r�r�r��r�r r r r�sr�cCstt��d|�S)zCReturn a list of records for the stack below the current exception.r)r�r��exc_infor�r r r �tracesr�cCstjd�|�S)Nrz)r rJr)�klassr r r �_static_getmrosr�cCs6i}zt�|d�}Wnty&Yn0t�||t�S�NrJ)r �__getattribute__r[r�r�� _sentinel)r,�attrZ instance_dictr r r �_check_instance s  r�c CsFt|�D]8}tt|��turz|j|WSty>Yq0qtSrg)r��_shadowed_dictr r�rJr�)r�r��entryr r r � _check_class)s  r�cCs&z t|�Wnty YdS0dS�NFT)r�r�r+r r r �_is_type2s   r�c Csltjd}t|�D]T}z|�|�d}Wnty:Yq0t|�tjur^|jdkr^|j|us|Sqt Sr�) r rJr�rr�rrr�rkr�)r�� dict_attrr�Z class_dictr r r r�9s   �� r�c Cst}t|�s>t|�}t|�}|tus2t|�tjurBt||�}n|}t||�}|tur�|tur�tt|�d�tur�tt|�d�tur�|S|tur�|S|tur�|S||ur�tt|��D]8}tt|��tur�z|j |WSt y�Yq�0q�|tur�|St |��dS)a�Retrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. rrN) r�r�r r�rrr�r�r�rJr�r[)r,r�r[Zinstance_resultr�r�Z klass_resultr�r r r �getattr_staticGs:  �  � r�� GEN_CREATED� GEN_RUNNING� GEN_SUSPENDED� GEN_CLOSEDcCs,|jr tS|jdurtS|jjdkr(tStS)a#Get current state of a generator-iterator. Possible states are: GEN_CREATED: Waiting to start execution. GEN_RUNNING: Currently being executed by the interpreter. GEN_SUSPENDED: Currently suspended at a yield expression. GEN_CLOSED: Execution has completed. Nr�)� gi_runningr��gi_framer��f_lastir�r�)� generatorr r r �getgeneratorstate|s   r�cCs:t|�std�|���t|dd�}|dur2|jjSiSdS)z� Get the mapping of generator local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values.z{!r} is not a Python generatorr�N)r3r�r�rLr�rh)r�rir r r �getgeneratorlocals�s  r�� CORO_CREATED� CORO_RUNNING�CORO_SUSPENDED� CORO_CLOSEDcCs,|jr tS|jdurtS|jjdkr(tStS)a&Get current state of a coroutine object. Possible states are: CORO_CREATED: Waiting to start execution. CORO_RUNNING: Currently being executed by the interpreter. CORO_SUSPENDED: Currently suspended at an await expression. CORO_CLOSED: Execution has completed. Nr�)� cr_runningr��cr_framer�r�r�r�)� coroutiner r r �getcoroutinestate�s   r�cCs"t|dd�}|dur|jSiSdS)z� Get the mapping of coroutine local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values.r�N)rLrh)r�rir r r �getcoroutinelocals�s r�� from_bytescCs6zt||�}Wnty"YdS0t|t�s2|SdS)z�Private helper. Checks if ``cls`` has an attribute named ``method_name`` and returns it only if it is a pure python function. N)rLr[r�_NonUserDefinedCallables)riZ method_name�methr r r �"_signature_get_user_defined_method�s   r�c Cs�|j}t|���}|jpd}|jp$i}|r2||}z|j|i|��}Wn8ty~}z d�|�} t| �|�WYd}~n d}~00d} |��D�] \} } z|j | } Wnt y�Ynl0| j t ur�|� | �q�| j tu�r| |vr�d} | j| d�|| <n|� | j�q�| j tu�r"| j| d�|| <| r�| j t u�s6J�| j tu�rf|| jtd�}||| <|�| �q�| j ttfv�r�|�| �q�| j tur�|� | j�q�|j|��d�S) z�Private helper to calculate how 'wrapped_sig' signature will look like after applying a 'functools.partial' object (or alike) on it. r z+partial object {!r} has incorrect argumentsNFT)r[�rx�rX)rXrrKr��keywords� bind_partialr�r�r�� argumentsr�rxrZr�r\rmrNr^� move_to_endr_r]rY)� wrapped_sig�partial� extra_argsZ old_params� new_paramsZ partial_argsZpartial_keywordsZbarbr�Ztransform_to_kwonly� param_namerfZ arg_valueZ new_paramr r r �_signature_get_partial�sN                r�cCslt|j���}|r$|djttfvr,td��|dj}|ttfvrP|dd�}n|t ur`td��|j |d�S)zWPrivate helper to transform signatures for unbound functions to bound methods. rzinvalid method signaturer�Nzinvalid argument typer�) rorXrYrxr_r^r�r\rZr]rm)ra�paramsrxr r r �_signature_bound_method0s  r�cCs&t|�p$t|�p$t|t�p$|ttfvS)zxPrivate helper to test if `obj` is a callable that might support Argument Clinic's __text_signature__ protocol. )rBrrr�r r r+r r r �_signature_is_builtinJs�� �r�cCs�t|�rt|�rdSt|dd�}t|dd�}t|dt�}t|dt�}t|dd�}t|tj�o�t|t�o�|dusxt|t�o�|dus�t|t �o�t|t �S)z�Private helper to test if `obj` is a duck type of FunctionType. A good example of such objects are functions compiled with Cython, which have all attributes that a pure Python function would have, but have their code statically compiled. Fr�Nr&� __defaults__�__kwdefaults__�__annotations__) �callablerrL�_voidrrr?r�ror�)r,rNr�rJrerdr r r �_signature_is_functionlikeVs       ����r�cCsr|�d�sJ�|�d�}|dkr*|�d�}|�d�}|dksH||ksHJ�|�d�}|dksf||ksfJ�|d|�S)z� Private helper to get first parameter name from a __text_signature__ of a builtin method, which should be in the following format: '($param1, ...)'. Assumptions are that the first argument won't have a default value or an annotation. z($�,r�r�:ryr)r��find)r�r�Zcposr r r �_signature_get_bound_paramos    rcCsd|s|ddfSd}d}dd�|�d�D�}t|�j}t�|�}d}d}g}|j} d} tj} tj} t|�} | j tj ksxJ�|D]�} | j | j }}|| kr�|dkr�|r�d}q||r�J�d}| d 7} q||d kr�|r�J�|dus�J�d}| d }q||| k�r|d k�r|du�s J�| }q||�r6d}|| k�r.|d k�s6| d �| |�|dkr|| d�q|d� |�}|||fS)a� Private helper function. Takes a signature in Argument Clinic's extended signature format. Returns a tuple of three things: * that signature re-rendered in standard Python syntax, * the index of the "self" parameter (generally 0), or None if the function does not have a "self" parameter, and * the index of the last "positional only" parameter, or None if the signature has no positional-only parameters. NcSsg|]}|�d��qS)�ascii)�encode)rh�lr r r r��rSz6_signature_strip_non_python_syntax..r�Frr�Tr��/�$rr�� r�) r�r$r%rrZr!�OP� ERRORTOKEN�nextr �ENCODING�stringr�)� signature�self_parameter�last_positional_onlyr�r�Z token_streamZ delayed_commaZskip_next_commar|r\Zcurrent_parameterrr �tr r �clean_signaturer r r �"_signature_strip_non_python_syntax�sZ       rTc shddl�|j�t|�\}}}d|d}z��|�}WntyLd}Yn0t|�j�shtd�|���|j d} g��j �t ��d}i�t |dd�} | r�t j�| d�}|r�|j�t j��� �fdd����� fd d �� G�� fd d �d �j���f��������fd d� } t| jj�} t| jj�} tj| | dd�}|du�rH�j�n�j�ttt|���D](\}\}}| ||�||k�r^�j��q^| jj�r��j�| | jj���j�t| jj | jj!�D]\}}| ||��q�| jj"�r�j#�| | jj"��|du�rZ��sJ�t |dd�}|du}t$|�}|�r@|�s4|�r@��%d�n�dj&�jd�} | �d<|�|j d�S)zdPrivate helper to parse content of '__text_signature__' and return a Signature based on it. rNzdef fooz: passz"{!r} builtin has invalid signaturer�cs(t|�j�sJ�|jdur"td��|jS)Nz'Annotations are not currently supported)rr}r`r�)r�)r�r r � parse_name�s z&_signature_fromstr..parse_namec sxzt|��}Wn:tyHzt|��}WntyBt��Yn0Yn0t|tttttt d�f�rn�� |�St��dSrg) �eval� NameError� RuntimeErrorrr��int�float�bytesr%r ZConstant)r�rO)r�� module_dict�sys_module_dictr r � wrap_value�s   z&_signature_fromstr..wrap_valuecs(eZdZ��fdd�Z��fdd�ZdS)z,_signature_fromstr..RewriteSymbolicscs\g}|}t|�j�r(|�|j�|j}qt|�j�s:t��|�|j�d�t |��}�|�S)Nr�) rrfrZr�rO�Namerr�r��reversed)r�r��ar�rO�r�rr r �visit_Attributes    z<_signature_fromstr..RewriteSymbolics.visit_Attributecst|j�j�st���|j�Srg)r�ctxZLoadr�r�r�r r r � visit_Namesz7_signature_fromstr..RewriteSymbolics.visit_NameN)r�r�r�r!r#r r r r �RewriteSymbolicss r$cs��|�}|�urdS|rn|turnz���|�}��|�}WntyP�}Yn0|�ur^dS|�urj|n|}���|�|�d��dS)N�r[r`)�_emptyr�Z literal_evalr�rZ)Z name_nodeZ default_noder[rN�o)� Parameterr$r�rW�invalidrxrXrr r �ps    z_signature_fromstr..p)� fillvaluer�r��rV)'r��_parameter_clsrr�� SyntaxErrorrZModuler�r��bodyrWr rLr�r�r�rJr�ZNodeTransformerrr�rJ� itertools� zip_longest�POSITIONAL_ONLY�POSITIONAL_OR_KEYWORDr�r9�vararg�VAR_POSITIONAL� KEYWORD_ONLYr�r>� kw_defaultsr�� VAR_KEYWORDr r�rm)rir,r�rQrrrZprogramr�r(� module_namer*r�rJr$r�rNr[Z_selfZ self_isboundZ self_ismoduler ) r(r$r�rWr)rxrrXrrrr �_signature_fromstr�sp�                     r:cCsBt|�std�|���t|dd�}|s4td�|���t||||�S)zHPrivate helper function to get signature for builtin callables. z%{!r} is not a Python builtin function�__text_signature__Nz#no signature found for builtin {!r})r�r�r�rLr�r:)rir�rQr�r r r �_signature_from_builtinXs� r<c CsHd}t|�s(t|�rd}ntd�|���t|dd�}|rFt||||�S|j}|j}|j}|j }|j } |d|�} |j } |||| �} |j } |j }|j}|r�t|�}nd}g}||}| }| d|�D]<}|r�tnt}| �|t�}|�||||d��|r�|d8}q�t| |d��D]L\}}|�r&tnt}| �|t�}|�||||||d ��|�r|d8}�q|jt@�r�||| }| �|t�}|�|||td��| D]B}t}|du�r�|�|t�}| �|t�}|�|||t|d ���q�|jt@�r2|| }|jt@�r |d7}||}| �|t�}|�|||td��||| �d t�|d �S) zCPrivate helper: constructs Signature for the given python function.FTr�r;Nr)r`rxr�)r`rxr[rS�rV�__validate_parameters__)rr�r�r�rLr:r-r&r7r6�co_posonlyargcountr8r�r�r�r�rZr\r�r&rZr�r'r:r]r^r;r_)rir�rQZis_duck_functionr�r(Z func_code� pos_count� arg_namesZ posonly_countr�Zkeyword_only_countZ keyword_onlyrdrJreZpos_default_countrXZnon_default_countZ posonly_leftrNrxr`�offsetr[r�r r r �_signature_from_functionhs�      �   �     �    �     � �rC)rPrQc Cs�tjt|||d�}t|�s(td�|���t|tj�rN||j �}|rJt |�S|S|rvt |dd�d�}t|tj�rv||�Sz |j }Wnt y�Yn&0|dur�t|t�s�td�|���|Sz |j}Wnt y�Yn�0t|tj��rZ||j�}t||d�}t|j���d }|jtju�r|St|j���} | �rD|| d u�sDJ�|f| } |j| d �St|��snt|��r|t|||d �St|��r�t|||d �St|tj��r�||j�}t||�Sd}t|t��r�t t|�d �} | du�r�|| �}nld} t |d �} t |d�}d |j!v�r| } n0d|j!v�r$|} n| du�r4| } n|du�rB|} | du�rT|| �}|du�rX|j"dd�D]<}z |j#}Wnt �y�Yn0|�rlt$|||�S�qlt|j"v�rX|j%t&j%u�r�|j't&j'u�r�|�(t&�St)d�|���nlt|t*��sXt t|�d �} | du�rXz || �}Wn:t)�yV}z d�|�}t)|�|�WYd}~n d}~00|du�rt|�rpt |�S|St|tj+��r�d�|�}t)|��t)d�|���dS)zQPrivate helper function to get signature for arbitrary callable objects. rOz{!r} is not a callable objectcSs t|d�S)N� __signature__rr�r r r rR�rSz*_signature_from_callable..r{Nz1unexpected object {!r} in __signature__ attributergrr�)rQ�__call__�__new__r�r�z(no signature found for builtin type {!r}zno signature found for {!r}z,no signature found for builtin function {!r}z+callable {!r} is not supported by signature),r#r�rTr�r�r�rrrr"r�r�rDr[rU�_partialmethod� partialmethodr�r�rorXrYrxr(r5rmrr�rCr�r<r r�rJrzr;r:r�r rF� from_callabler�r�rA)r,rPrQrRZ_get_signature_ofrarHr�Zfirst_wrapped_paramZ sig_paramsr��callZfactory_method�new�initrPZtext_sigrbr�r r r rT�s� �      ��     �  � �                � �       rTc@seZdZdZdS)r�z1A private marker - used in Parameter & Signature.N�r�r�r�r�r r r r r�} sr�c@seZdZdZdS)r&z6Marker object for Signature.empty and Parameter.empty.NrMr r r r r&� sr&c@s4eZdZdZdZdZdZdZdd�Ze dd ��Z d S) �_ParameterKindrr�r��cCs|jSrg)�_name_rr r r �__str__� sz_ParameterKind.__str__cCst|Srg)�_PARAM_NAME_MAPPINGrr r r � description� sz_ParameterKind.descriptionN) r�r�r�r2r3r5r6r8rRrlrTr r r r rN� srNzpositional-onlyzpositional or keywordzvariadic positionalr�zvariadic keywordc@s�eZdZdZdZeZeZe Z e Z e ZeZeed�dd�Zdd�Zdd �Zed d ��Zed d ��Zedd��Zedd��Zeeeed�dd�Zdd�Zdd�Zdd�Zdd�ZdS)r(aRepresents a parameter in a function signature. Has the following public attributes: * name : str The name of the parameter as a string. * default : object The default value for the parameter if specified. If the parameter has no default value, this attribute is set to `Parameter.empty`. * annotation The annotation for the parameter if specified. If the parameter has no annotation, this attribute is set to `Parameter.empty`. * kind : str Describes how argument values are bound to the parameter. Possible values: `Parameter.POSITIONAL_ONLY`, `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`, `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`. )�_name�_kind�_default� _annotationr%cCszt|�|_Wn"ty0td|�d���Yn0|turb|jttfvrbd}|�|jj�}t|��||_||_ |tur~td��t |t �s�d�t |�j �}t|��|ddkr�|dd���r�|jtkr�d }|�|jj�}t|��t|_d �|dd��}|���std �|���||_dS) Nzvalue z is not a valid Parameter.kindz({} parameters cannot have default valuesz*name is a required attribute for Parameterzname must be a str, not a {}rr�r�zLimplicit arguments must be passed as positional or keyword arguments, not {}z implicit{}z"{!r} is not a valid parameter name)rNrVr�r&r]r_r�rTrWrXrr�r r�r��isdigitr\rZ� isidentifierrU)r�rNrxr[r`r�r r r r�� s6   � zParameter.__init__cCs t|�|j|jf|j|jd�fS)N�rWrX)r rUrVrWrXrr r r � __reduce__� s  ��zParameter.__reduce__cCs|d|_|d|_dS)NrWrXr[�r��stater r r � __setstate__� s zParameter.__setstate__cCs|jSrg)rUrr r r rN� szParameter.namecCs|jSrg)rWrr r r r[� szParameter.defaultcCs|jSrg)rXrr r r r`� szParameter.annotationcCs|jSrg)rVrr r r rx szParameter.kind)rNrxr`r[cCsL|tur|j}|tur|j}|tur*|j}|tur8|j}t|�||||d�S)z+Creates a customized copy of the Parameter.r%)r�rUrVrXrWr )r�rNrxr`r[r r r rm szParameter.replacecCs�|j}|j}|jtur(d�|t|j��}|jturb|jturPd�|t|j��}nd�|t|j��}|tkrtd|}n|t kr�d|}|S)Nz{}: {}z{} = {}z{}={}rtrw) rxrUrXr&r�rorWrlr]r_)r�rx� formattedr r r rR s �   zParameter.__str__cCsd�|jj|�S)Nz <{} "{}">�r�r�r�rr r r �__repr__, szParameter.__repr__cCst|j|j|j|jf�Srg)�hashrNrxr`r[rr r r �__hash__/ szParameter.__hash__cCsJ||ur dSt|t�stS|j|jkoH|j|jkoH|j|jkoH|j|jkS�NT)rr(�NotImplementedrUrVrWrX�r��otherr r r �__eq__2 s   � � �zParameter.__eq__N)r�r�r�r�r�rZr2r\r3r]r5r^r6r_r8r&rWr�r\r_rlrNr[r`rxr�rmrRrbrdrir r r r r(� s4(    � r(c@sheZdZdZdZdd�Zedd��Zedd��Zed d ��Z d d �Z d d�Z dd�Z dd�Z dd�ZdS)�BoundArgumentsa�Result of `Signature.bind` call. Holds the mapping of arguments to the function's parameters. Has the following public attributes: * arguments : dict An ordered mutable mapping of parameters' names to arguments' values. Does not contain arguments' default values. * signature : Signature The Signature object that created this instance. * args : tuple Tuple of positional arguments values. * kwargs : dict Dict of keyword arguments values. )r�� _signature� __weakref__cCs||_||_dSrg)r�rk)r�r r�r r r r�P szBoundArguments.__init__cCs|jSrg)rkrr r r r T szBoundArguments.signaturec Cs|g}|jj��D]b\}}|jttfvr*qtz|j|}WntyPYqtYq0|jtkrh|� |�q|� |�qt |�Srg) rkrXrKrxr_r^r�r�r]�extendrZro)r�r�r�rfr}r r r r�X s     zBoundArguments.argsc Cs�i}d}|jj��D]v\}}|sD|jttfvr4d}n||jvrDd}q|sJqz|j|}WntyjYq0|jtkr�|�|�q|||<q|Sr�) rkrXrKrxr_r^r�r��update)r��kwargsZkwargs_startedr�rfr}r r r roo s&     zBoundArguments.kwargsc Cs�|j}g}|jj��D]v\}}z|�|||f�Wqty�|jturT|j}n$|jt urdd}n|jt urti}nYq|�||f�Yq0qt |�|_dS)z�Set default values for missing arguments. For variable-positional arguments (*args) the default is an empty tuple. For variable-keyword arguments (**kwargs) the default is an empty dict. r N) r�rkrXrKrZr�r[r&rxr]r_r�)r�r�Z new_argumentsrNrf�valr r r �apply_defaults� s     zBoundArguments.apply_defaultscCs2||ur dSt|t�stS|j|jko0|j|jkSre)rrjrfr r�rgr r r ri� s   �zBoundArguments.__eq__cCs|d|_|d|_dS)Nrkr��rkr�r]r r r r_� s zBoundArguments.__setstate__cCs|j|jd�S)Nrrrrrr r r � __getstate__� szBoundArguments.__getstate__cCs@g}|j��D]\}}|�d�||��qd�|jjd�|��S)Nz{}={!r}z <{} ({})>r�)r�rKrZr�r�r�r�)r�r�r}rOr r r rb� szBoundArguments.__repr__N)r�r�r�r�r�r�rlr r�rorqrir_rsrbr r r r rj= s   rjc@s�eZdZdZdZeZeZe Z d,e dd�dd�Z e dd ��Z e d d ��Ze dd �d d��Zedd��Zedd��Zeed�dd�Zdd�Zdd�Zdd�Zdd�dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�ZdS)-rUaA Signature object represents the overall signature of a function. It stores a Parameter object for each parameter accepted by the function, as well as information specific to the function itself. A Signature object has the following public attributes and methods: * parameters : OrderedDict An ordered mapping of parameters' names to the corresponding Parameter objects (keyword-only arguments are in the same order as listed in `code.co_varnames`). * return_annotation : object The annotation for the return type of the function if specified. If the function has no annotation for its return type, this attribute is set to `Signature.empty`. * bind(*args, **kwargs) -> BoundArguments Creates a mapping from positional and keyword arguments to parameters. * bind_partial(*args, **kwargs) -> BoundArguments Creates a partial mapping from positional and keyword arguments to parameters (simulating 'functools.partial' behavior.) )�_return_annotation� _parametersNTr=c Cs�|durt�}n�|r�t�}t}d}|D]�}|j}|j} ||kr\d} | �|j|j�} t| ��n||krld}|}|ttfvr�|jt ur�|r�d} t| ��nd}| |vr�d�| �} t| ��||| <q&ntdd�|D��}t � |�|_ ||_ dS) z�Constructs Signature from the given list of Parameter objects and 'return_annotation'. All arguments are optional. NFz7wrong parameter order: {} parameter before {} parameterz-non-default argument follows default argumentTzduplicate parameter name: {!r}css|]}|j|fVqdSrgru�rhrfr r r rj rSz%Signature.__init__..)rrZrxrNr�rTr�r\r[r&r�MappingProxyTyperurt) r�rXrVr>r�Ztop_kindZ kind_defaultsrfrxrNr�r r r r�� s@��       zSignature.__init__cCstjdtdd�t||�S)z�Constructs Signature for the given python function. Deprecated since Python 3.5, use `Signature.from_callable()`. z_inspect.Signature.from_function() is deprecated since Python 3.5, use Signature.from_callable()rrD)rFrGrHrC�rir�r r r � from_function s�zSignature.from_functioncCstjdtdd�t||�S)z�Constructs Signature for the given builtin function. Deprecated since Python 3.5, use `Signature.from_callable()`. z^inspect.Signature.from_builtin() is deprecated since Python 3.5, use Signature.from_callable()rrD)rFrGrHr<rxr r r � from_builtin s�zSignature.from_builtin��follow_wrappedcCst|||d�S)z3Constructs Signature for the given callable object.)rRrP)rT)rir,r|r r r rI+ s�zSignature.from_callablecCs|jSrg)rurr r r rX1 szSignature.parameterscCs|jSrg�rtrr r r rV5 szSignature.return_annotation)rXrVcCs0|tur|j��}|tur |j}t|�||d�S)z�Creates a customized copy of the Signature. Pass 'parameters' and/or 'return_annotation' arguments to override them in the new copy. r,)r�rXrYrtr )r�rXrVr r r rm9 s �zSignature.replacecCs8tdd�|j��D��}dd�|j��D�}|||jfS)Ncss|]}|jtkr|VqdSrg)rxr^rvr r r rjI s �z(Signature._hash_basis..cSsi|]}|jtkr|j|�qSr )rxr^rNrvr r r r�L s �z)Signature._hash_basis..)rorXrYrV)r�r�� kwo_paramsr r r � _hash_basisH szSignature._hash_basiscCs(|��\}}}t|���}t|||f�Srg)r� frozensetrYrc)r�r�r~rVr r r rdQ s zSignature.__hash__cCs*||ur dSt|t�stS|��|��kSre)rrUrfrrgr r r riV s  zSignature.__eq__F�r�c Cs�i}t|j���}d}t|�}z t|�}Wn�t�yz t|�} Wnty`YY�q�Yn�0| jtkrtY�q�n�| j|vr�| jtkr�d} | j | jd�} t | �d�| f}Y�q�nP| jt ks�| j t ur�| f}Y�q�n.|r�| f}Y�q�nd} | j | jd�} t | �d�Yq0z t|�} Wnt�y2t d�d�Yq0| jt tfv�rNt d�d�| jtk�r||g} | �|�t| �|| j<�q�| j|v�r�| jtk�r�t dj | jd��d�||| j<qd} t�||�D]�} | jt k�r�| } �q�| jtk�r�q�| j} z|�| �}WnDt�yD|�s@| jtk�r@| j t u�r@t dj | d��d�Yn(0| jtk�rdt dj | jd���||| <�q�|�r�| du�r�||| j<nt dj tt|��d���|�||�S) z#Private method. Don't use directly.r zA{arg!r} parameter is positional only, but was passed as a keyword)r}Nz$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})r$rXrYr � StopIterationrxr]rNrZr�r�r_r[r&r^rmror0�chainr�r��_bound_arguments_cls)r�r�ror�r�rXZ parameters_exZarg_valsZarg_valrfr�rYZ kwargs_paramr�r r r �_bind] s�        � ��  ���   ��� �    ��zSignature._bindcOs |�||�S)z�Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. �r��r�r�ror r r �bind� szSignature.bindcOs|j||dd�S)z�Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature. Raises `TypeError` if the passed arguments can not be bound. Tr�r�r�r r r r�� szSignature.bind_partialcCs t|�t|j���fd|jifS�Nrt)r rorurYrtrr r r r\� s�zSignature.__reduce__cCs|d|_dSr�r}r]r r r r_� szSignature.__setstate__cCsd�|jj|�S)Nz<{} {}>rarr r r rb� szSignature.__repr__c Cs�g}d}d}|j��D]d}t|�}|j}|tkr6d}n|rH|�d�d}|tkrVd}n|tkrp|rp|�d�d}|�|�q|r�|�d�d�d� |��}|j t ur�t |j �}|d�|�7}|S)NFTrrtz({})r�z -> {}) rXrYr�rxrZrZr]r^r�r�rVr&ro) r�rvZrender_pos_only_separatorZrender_kw_only_separatorrfr`rxZrenderedZannor r r rR� s0       zSignature.__str__)N)r�r�r�r�r�r(r-rjr�r&rWr�rtryrzrIrlrXrVr�rmrrdrir�r�r�r\r_rbrRr r r r rU� s<� 6     rUr{cCstj||d�S)z/Get a signature object for the passed callable.r{)rUrI)r,r|r r r r ' sr c Cs�ddl}ddl}|��}|jddd�|jdddd d �|��}|j}|�d �\}}}z|�|�}} WnPty�} z8d � |t | �j | �} t | t jd �t �d�WYd} ~ n d} ~ 00|r�|�d�} | }| D]} t|| �}q�| j t jv�rt dt jd �t �d�|j�r�t d� |��t d� t| ���t d� | j��|| u�rzt d� t| j���t| d��r�t d� | j��n4zt|�\}}Wnt�y�Yn0t d� |��t d�n t t|��dS)z6 Logic for inspecting an object given at command line rNr zCThe object to be analysed. It supports the 'module:qualname' syntax)�helpz-dz --details� store_truez9Display info about the module rather than its source code)�actionr�r�zFailed to import {} ({}: {}))r�rr�z#Can't get info for builtin modules.r�z Target: {}z Origin: {}z Cached: {}z Loader: {}�__path__zSubmodule search path: {}zLine: {}r�)�argparser��ArgumentParser� add_argument� parse_argsr � partition� import_modulerpr�r r��printr��stderr�exitr�rL�builtin_module_names�detailsr�� __cached__rlr�rr�rr,)r�r��parserr��target�mod_nameZ has_attrs�attrsr,r�rwr��parts�part�__r�r r r �_main, s\���       r�r�)N)N)N)F)N)r�)r�)r�)r�)r�)r )T)T)T)�r�� __author__r8r��dis�collections.abcr7�enum�importlib.machineryr�r0r�r�r�r�rr!rrFr#r��operatorrrr�globalsZmod_dictZCOMPILER_FLAG_NAMESrKrcrdrGr rrrrrrr rr*r-r.r/r1r3r5r:r<r>r@rBrCrQrerfryrVr�r�r�r�r�r�r�r�r�r�r�r�r�rpr�Z NodeVisitorr�rr r r r(r+r,r-r4r5rBrCrMrNrIrgrjrorrr�r�r�r�r�r�r�r�r�r�r��_fieldsr�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 rEZ_WrapperDescriptor�allZ_MethodWrapperrrJZ_ClassMethodWrapperrAr�r�r�r�r�r�rrr:r<rCrTr�r&�IntEnumrNr2rZr3r\r5r]r6r^r8r_rSr(rjrUr r�r�r r r r �sr            , t$ >   /D->     �\  � ;� < 5        0  � L H   _� 8� j: