grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B ÐhD³* ÒÐã @s”dZdZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlmZddlmZmZeƒZx"ej ¡D]\ZZeede<q¶WdZdd „Zd d „Z d d „Z!dd„Z"dd„Z#e$edƒ�rdd„Z%ndd„Z%e$edƒ�r.dd„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+„Z/d,d-„Z0d.d/„Z1d0d1„Z2d2d3„Z3d4d5„Z4dôd6d7„Z5ed8d9ƒZ6d:d;„Z7dœd?d@„Z9dAdB„Z:dCdD„Z;dEdF„ZdKdL„Z?dMdN„Z@dOdP„ZAdõdQdR„ZBiZCiZDdödSdT„ZEdUdV„ZFdWdX„ZGGdYdZ„dZeHƒZIGd[d\„d\ƒZJd]d^„ZKd_d`„ZLdadb„ZMdcdd„ZNd÷dfdg„ZOedhdiƒZPdjdk„ZQdldm„ZRedndoƒZSdpdq„ZTedrdsƒZUdtdu„ZVedvdwƒZWdxdy„ZXdødzd{„ZYd|d}„ZZdddd~iie[dd€„d�d€„d‚d€„dƒd€„eYf d„d…„Z\e[d†d€„d‡d€„dˆd€„fd‰dŠ„Z]d‹dŒ„Z^d�dŽ„Z_d�d�„Z`ed‘d’ƒZad“d”„Zbed•d–ƒZcdùd˜d™„Zddšd›„Zeedœd�ecjfƒZgdúdždŸ„Zhdûd d¡„Zid¢d£„Zjdüd¤d¥„Zkdýd¦d§„ZlemƒZnd¨d©„Zodªd«„Zpd¬d­„Zqd®d¯„Zrd°d±„Zsenfd²d³„Ztd´ZudµZvd¶Zwd·Zxd¸d¹„Zydºd»„Zzd¼Z{d½Z|d¾Z}d¿Z~dÀdÁ„ZdÂdÄZ€e�e�j‚ƒZƒe�e„j‚ƒZ…e�e†j‡dăZˆeƒe…eˆej‰fZŠdÅdÆ„Z‹dþdÇdÈ„ZŒdÉdÊ„Z�dËdÌ„ZŽdÍd΄Z�dÏdЄZ�dÑdÒ„Z‘dÿdÔdÕ„Z’�ddÖdׄZ“dØ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¤e¤j¥Z¦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 ú,/opt/alt/python37/lib64/python3.7/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Útype)rr r r ÚisclassHsr cCs 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Ú MethodType)rr r r ÚismethodPsrcCs: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__)r rÚ isfunctionr Úhasattr)rÚtpr r r ÚismethoddescriptorZsrcCs8t|ƒst|ƒst|ƒrdSt|ƒ}t|dƒo6t|dƒS)a€Return true if the object is a data descriptor. Data descriptors have both a __get__ and a __set__ 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.Frr)r rrr r)rrr r r ÚisdatadescriptornsrÚMemberDescriptorTypecCs t|tjƒS)z�Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.)rrr)rr r r Úismemberdescriptor~srcCsdS)z�Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.Fr )rr r r r†sÚGetSetDescriptorTypecCs t|tjƒS)z�Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.)rrr)rr r r Úisgetsetdescriptor�srcCsdS)z�Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.Fr )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Ú FunctionType)rr r r ržs rcCs tt|ƒst|ƒo|jjt@ƒ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.)ÚboolrrÚ__code__Úco_flagsZ CO_GENERATOR)rr r r Úisgeneratorfunction«srcCs tt|ƒst|ƒo|jjt@ƒS)zuReturn true if the object is a coroutine function. Coroutine functions are defined with "async def" syntax. )rrrrrZ CO_COROUTINE)rr r r Úiscoroutinefunction³sr cCs tt|ƒst|ƒo|jjt@ƒ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. )rrrrrZCO_ASYNC_GENERATOR)rr r r Úisasyncgenfunction»sr!cCs t|tjƒS)z7Return true if the object is an asynchronous generator.)rrÚAsyncGeneratorType)rr r r Ú isasyncgenÄsr#cCs 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Ú GeneratorType)rr r r Ú isgeneratorÈsr%cCs t|tjƒS)z)Return true if the object is a coroutine.)rrÚ CoroutineType)rr r r Ú iscoroutineÙsr'cCs6t|tjƒp4t|tjƒr(t|jjt@ƒp4t|tj j ƒS)z?Return true if object can be passed to an ``await`` expression.) rrr&r$rÚgi_coderZCO_ITERABLE_COROUTINEÚ collectionsÚabcÚ Awaitable)rr 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Ú TracebackType)rr 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Ú FrameType)rr r r Úisframeîs r0cCs t|tjƒS)aEReturn 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_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 of local variables co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables)rrÚCodeType)rr r r Úiscodeüsr2cCs 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ÚBuiltinFunctionType)rr r r Ú isbuiltinsr4cCs t|ƒpt|ƒpt|ƒpt|ƒS)zdSx&|j  ¡D]\}}t |ddƒrJdSqJWx@|j D]6}x0t |ddƒD] }t ||dƒ}t |ddƒr€dSq€WqnWdS)z:Return true if the object is an abstract base class (ABC).FTÚ__abstractmethods__Ú__isabstractmethod__r N) rr Ú __flags__ÚTPFLAGS_IS_ABSTRACTÚ issubclassr*ÚABCMetarÚ__dict__ÚitemsÚgetattrÚ __bases__)rÚnameÚvalueÚbaser r r Ú isabstract$s"        rCc Cs$t|ƒr|ft|ƒ}nd}g}tƒ}t|ƒ}yBx<|jD]2}x,|j ¡D]\}}t|tj ƒrH|  |¡qHWq8WWnt k r„YnXxˆ|D]€} yt || ƒ} | |kr¨t ‚Wn:t k räx$|D]}| |jkrÀ|j| } PqÀWwŒYnX|rô|| ƒ�r|  | | f¡|  | ¡qŒW|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 Úeózgetmembers..)Úkey)r ÚgetmroÚsetÚdirr?r<r=rrÚDynamicClassAttributeÚappendÚAttributeErrorr>ÚaddÚsort) rZ predicateÚmroÚresultsÚ processedÚnamesrBÚkÚvrFrAr r r Ú getmembers<s:       rUÚ Attributezname kind defining_class objectc Csht|ƒ}tt|ƒƒ}tdd„|Dƒƒ}|f|}||}t|ƒ}x:|D]2}x,|j ¡D]\}}t|tjƒrV|  |¡qVWqFWg} t ƒ} �xÚ|D�]Ð} d} d} d}| | k�rŒy| dkr¼t dƒ‚t || ƒ} Wn"t k rê}zWdd}~XYn¢Xt | d| ƒ} | |k�rŒd} d}x(|D] }t || dƒ}|| k�r|}�qWxH|D]@}y|  || ¡}Wntk �rh�w:YnX|| k�r:|}�q:W|dk �rŒ|} x4|D],}| |jk�r’|j| }| |k�rº|} P�q’W| dk�rÎqŽ| dk �rÜ| n|}t|ttjfƒ�rüd}|}nFt|ttjfƒ�rd}|}n*t|tƒ�r.d }|}nt|ƒ�r>d }nd }|   t| || |ƒ¡|  | ¡qŽW| 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|]}|ttfkr|VqdS)N)r r)Ú.0Úclsr r r ú ‡sz'classify_class_attrs..Nr<z)__dict__ is special, don't want the proxyÚ __objclass__z static methodz class methodÚpropertyÚmethodÚdata)rGr ÚtuplerIr<r=rrrJrKrHÚ Exceptionr>Ú __getattr__rLÚ staticmethodÚBuiltinMethodTypeÚ classmethodÚClassMethodDescriptorTyper[r5rVrM)rXrOZmetamroZ class_basesZ all_basesrRrBrSrTÚresultrQr@ZhomeclsZget_objZdict_objÚexcZlast_clsZsrch_clsZsrch_objÚobjÚkindr r r Úclassify_class_attrsjs€                        ricCs|jS)zHReturn tuple of base classes (including cls) in method resolution order.)Ú__mro__)rXr r r rGÞsrG)Ústopcs€ˆdkrdd„}n ‡fdd„}|}t|ƒ|i}t ¡}xD||ƒrz|j}t|ƒ}||ksbt|ƒ|krptd |¡ƒ‚|||<q8W|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)Úfr r r Ú _is_wrapperõszunwrap.._is_wrappercst|dƒoˆ|ƒ S)Nrl)r)rm)rkr r rnøsz!wrapper loop when unwrapping {!r})ÚidÚsysÚgetrecursionlimitrlÚlenÚ ValueErrorÚformat)ÚfuncrkrnrmZmemoZrecursion_limitZid_funcr )rkr Úunwrapäs     rvcCs| ¡}t|ƒt| ¡ƒS)zBReturn the indent size, in spaces, at the start of a line of text.)Ú expandtabsrrÚlstrip)ÚlineZexpliner r r Ú indentsizesrzcCsRtj |j¡}|dkrdSx&|j d¡dd…D]}t||ƒ}q0Wt|ƒsNdS|S)NÚ.éÿÿÿÿ)rpÚmodulesÚgetÚ __module__Ú __qualname__Úsplitr>r )rurXr@r r r Ú _findclass sr‚c CsÖt|ƒrRxD|jD]:}|tk ry |j}Wntk r<wYnX|dk r|SqWdSt|ƒr–|jj}|j}t|ƒrŽt t ||dƒdƒ|jkrŽ|}n|j }nðt |ƒrÈ|j}t |ƒ}|dksÂt ||ƒ|k rÆdSn¾t |ƒ�r |j}|j}t|ƒ�r|jd||jk�r|}n|j }nzt|tƒ�rL|j}|j}t |ƒ}|dk�sFt ||ƒ|k �r†dSn:t|ƒ�s`t|ƒ�r‚|j}|j}t ||ƒ|k �r†dSndSxJ|jD]@}yt ||ƒj}Wntk �r¼�wŽYnX|dk �rŽ|S�qŽWdS)NÚ__func__r{)r rjrÚ__doc__rLrrƒÚ__name__Ú__self__r>Ú __class__rr‚r4r€rr[ÚfgetrrrZ)rgrBÚdocr@ÚselfrXrur r r Ú_finddocsb         r‹c Csdy |j}Wntk rdSX|dkrNy t|ƒ}Wnttfk rLdSXt|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„rLr‹Ú TypeErrorrÚstrÚcleandoc)rr‰r r r ÚgetdocRs   r�cCsøy| ¡ d¡}Wntk r&dSXtj}x:|dd…D]*}t| ¡ƒ}|rr›rŒrtr rrpr}r~rrrƒrrr.Útb_framer0Úf_coder2Ú co_filenamer r…)rÚmoduler r r Úgetfile‚s,   r cCsTtj |¡}dd„tj ¡Dƒ}| ¡x&|D]\}}| |¡r.|d|…Sq.WdS)z1Return the module name for a given file, or None.cSsg|]}t|ƒ |f‘qSr )rr)rWÚsuffixr r r ú  sz!getmodulename..N)ÚosÚpathÚbasenameÚ importlibÚ machineryÚ all_suffixesrNÚendswith)r¤ZfnameÚ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ƒdk r¨ˆSˆtjkr¶ˆ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|]}ˆ |¡VqdS)N)r©)rWÚs)Úfilenamer r rY¯sz getsourcefile..rc3s|]}ˆ |¡VqdS)N)r©)rWr¬)r­r r rY²sÚ __loader__)r r¦r§ÚDEBUG_BYTECODE_SUFFIXESÚOPTIMIZED_BYTECODE_SUFFIXESÚanyr£r¤ÚsplitextÚSOURCE_SUFFIXESÚEXTENSION_SUFFIXESÚexistsr>Ú getmoduleÚ linecacheÚcache)rZall_bytecode_suffixesr )r­r Ú getsourcefile¨s   r¹cCs,|dkrt|ƒ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|dk rD|tkrDtj t|¡Syt||ƒ}Wntk rfdSX|tkr€tj t|¡Sxntj  ¡  ¡D]\\}}t|ƒr�t|dƒr�|j }|t  |d¡krÂq�|t |<t|ƒ}|j t|<ttj |¡<q�W|tk�r tj t|¡Stjd}t|dƒ�s$dSt||j ƒ�rLt||j ƒ}||k�rL|Stjd}t||j ƒ�r~t||j ƒ} | |k�r~|SdS)zAReturn the module an object was defined in, or None if not found.rNr›Ú__main__r…Úbuiltins)r rrpr}r~rÚ modulesbyfiler½rŒÚcopyr=r›Ú_filesbymodnamer…r£r¤Úrealpathr>) rr¼ÚfileÚmodnamerŸrmÚmainZ mainobjectZbuiltinZ builtinobjectr r r r¶ÊsD         r¶c CsÒt|ƒ}|rt |¡n$t|ƒ}| d¡r4| d¡szsource code not availablezcould not get source coderz^(\s*)class\s*z\bÚcr‘zcould not find class definitionÚco_firstlinenoz"could not find function definitionz>^(\s*def\s)|(\s*async\s+def\s)|(.*(?yt|ƒ\}}Wnttfk r(dSXt|ƒròd}|rR|ddd…dkrRd}x(|t|ƒkrz|| ¡dkrz|d}qTW|t|ƒkrî||dd…dkrîg}|}x>|t|ƒkrâ||dd…dkrâ| || ¡¡|d}q¦Wd |¡S�nH|dk�r:t ||ƒ}|d}|dk�r:||  ¡dd…dk�r:t ||ƒ|k�r:|| ¡  ¡g}|dk�rØ|d}|| ¡  ¡}x\|dd…dk�rÖt ||ƒ|k�rÖ|g|dd…<|d}|dk�rÂP|| ¡  ¡}�q|Wx*|�r|d ¡dk�rg|dd…<�qÚWx*|�r.|d  ¡dk�r.g|d d…<�qWd |¡SdS) zwGet lines of comments immediately preceding an object's source code. Returns None when source can't be found. Nréz#!r‘)Úú#r×rÖr|) rÔrÍrŒr rrÚstriprKrwr—rzrx)rr˜rÓÚstartZcommentsÚendr™Úcommentr r r Ú getcommentsAsJ  "   $ & rÜc@s eZdZdS)Ú EndOfBlockN)r…rr€r r r r rÝnsrÝc@s eZdZdZdd„Zdd„ZdS)Ú BlockFinderz@Provide a tokeneater() method to detect the end of a code block.cCs.d|_d|_d|_d|_d|_d|_d|_dS)NrFr‘)r™ÚislambdaÚstartedÚpasslineÚ indecoratorÚdecoratorhasargsÚlast)rŠr r r Ú__init__rszBlockFinder.__init__cCs|js@|js@|dkrd|_n|dkr8|dkr2d|_d|_d|_nØ|dkrV|jrTd|_nÂ|dkrr|jrpd|_d|_n¦|tjkrªd|_|d|_|jr–t‚|jr¨|js¨d|_nn|jr²nf|tj krÐ|j d |_ d|_nH|tj krö|j d |_ |j dkrôt‚n"|j dk�r|tj tj fk�rt‚dS) Nú@T)ÚdefÚclassÚlambdaréú(ú)Frr‘)ràrârßrárãÚtokenizeÚNEWLINErärÝÚINDENTr™ÚDEDENTÚCOMMENTÚNL)rŠr ÚtokenZsrowcolZerowcolryr r r Ú tokeneater{sB         zBlockFinder.tokeneaterN)r…rr€r„rårór r r r rÞps rÞc CsZtƒ}y,t t|ƒj¡}x|D]}|j|ŽqWWnttfk rJYnX|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§s rù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‘) rvrÔr.rœr r0r�Úco_namerù)rr˜rÓr 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—)rr˜rÓr r r Ú getsourceÇs rücCsVg}|jtddƒd�x:|D]2}| ||jf¡||kr| t||||ƒ¡qW|S)z-Recursive helper function for getclasstree().rr…)rF)rNrrKr?Úwalktree)ÚclassesÚchildrenÚparentrPrÉr r r rýÑs rýFcCs¤i}g}xn|D]f}|jrbxZ|jD]<}||kr4g||<|||krN|| |¡|r ||kr Pq Wq||kr| |¡qWx|D]}||kr~| |¡q~Wt||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)r?rKrý)rþÚuniquerÿÚrootsrÉrr r r Ú getclasstreeÛs"      rÚ Argumentszargs, varargs, varkwcCs t|ƒ\}}}}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.)Ú _getfullargsr)ÚcoÚargsÚvarargsÚ kwonlyargsÚvarkwr r r Úgetargsøsr c Csœt|ƒstd |¡ƒ‚|j}|j}|j}t|d|…ƒ}t||||…ƒ}d}||7}d}|jt@rx|j|}|d}d}|jt @r�|j|}||||fS)aGet information about the arguments accepted by a code object. Four things are returned: (args, varargs, kwonlyargs, varkw), where 'args' and 'kwonlyargs' are lists of argument names, and 'varargs' and 'varkw' are the names of the * and ** arguments or None.z{!r} is not a code objectNrr‘) r2rŒrtÚ co_argcountÚ co_varnamesÚco_kwonlyargcountÚlistrÚ CO_VARARGSÚCO_VARKEYWORDS) rÚnargsrRZnkwargsrr Ústeprr r r r rs"    rÚ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Õ)Ú stacklevelzdFunction has keyword-only parameters or annotations, use getfullargspec() API which can support them)ÚwarningsÚwarnÚDeprecationWarningÚgetfullargspecrsr)rurrr Údefaultsr ÚkwonlydefaultsÚannr r r Ú getargspec s  rÚ FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc Cs`yt|ddtd�}Wn,tk r@}ztdƒ|‚Wdd}~XYnXg}d}d}g}d}i}d}i} |j|jk rx|j|d<x¾|j ¡D]°} | j} | j } | t kr¨|  | ¡nv| t krÔ|  | ¡| j | jk rÒ|| j f7}nJ| tkrâ| }n<| tk�r|  | ¡| j | jk �r| j | | <n| tk�r| }| j| jk r„| j|| <q„W| �sBd} |�sLd}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Ú Signaturer_rŒÚreturn_annotationÚemptyÚ parametersÚvaluesrhr@Ú_POSITIONAL_ONLYrKÚ_POSITIONAL_OR_KEYWORDÚdefaultÚ_VAR_POSITIONALÚ _KEYWORD_ONLYÚ _VAR_KEYWORDÚ annotationr) ruÚsigÚexrrr r rÚ annotationsÚ kwdefaultsÚparamrhr@r r r rAsT            rÚ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.)r r�r5Úf_locals)Úframerrr r r r Ú getargvaluesžsr8cCsVt|ddƒdkr t|ƒ dd¡St|tƒrN|jd|fkr>|jS|jd|jSt|ƒS)NrÚtypingztyping.rÖr¿r{)r>ÚreprÚreplacerr rr€)r/Z base_moduler r r Úformatannotation¨s r<cst|ddƒ‰‡fdd„}|S)Nrcs t|ˆƒS)N)r<)r/)rŸr r Ú_formatannotation³sz5formatannotationrelativeto.._formatannotation)r>)rr=r )rŸr Úformatannotationrelativeto±s  r>r cCsd|S)NÚ*r )r@r r r rDºrErDcCsd|S)Nz**r )r@r r r rD»rEcCs dt|ƒS)Nú=)r:)rAr r r rD¼rEcCsd|S)Nz -> r )Útextr r r rD½rEc sDddlm} | dtdd�‡‡‡fdd„}g}|rBt|ƒt|ƒ}xFt|ƒD]:\}}||ƒ}|r|||kr||| |||ƒ}| |¡qLW|dk r¦| |||ƒƒ¡n|r´| d ¡|rôx:|D]2}||ƒ}|ræ||kræ|| ||ƒ7}| |¡q¾W|dk �r| | ||ƒƒ¡d d  |¡d }d ˆk�r@|| ˆˆ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)rzc`formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directlyrÕ)rcs(ˆ|ƒ}|ˆkr$|dˆˆ|ƒ7}|S)Nz: r )Úargre)r2r<Ú formatargr r ÚformatargandannotationÒsz-formatargspec..formatargandannotationNr?rêz, rër")rrrrrÚ enumeraterKr—)rrr rr rr2rCÚ formatvarargsÚ formatvarkwÚ formatvalueZ formatreturnsr<rrDÚspecsZ firstdefaultršrBÚspecZ kwonlyargrer )r2r<rCr Ú formatargspec·s:       rKcCsd|S)Nr?r )r@r r r rDórEcCsd|S)Nz**r )r@r r r rDôrEcCs dt|ƒS)Nr@)r:)rAr r r rDõrEc CsŠ|||fdd„}g} x&tt|ƒƒD]} |  ||| ƒ¡q"W|rZ|  ||ƒ|||ƒ¡|rx|  ||ƒ|||ƒ¡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||ƒ|||ƒS)Nr )r@ÚlocalsrCrHr r r Úconvertüsz formatargvalues..convertrêz, rë)r•rrrKr—) rrr rLrCrFrGrHrMrIršr r r Úformatargvaluesñs rNcs˜‡fdd„|Dƒ}t|ƒ}|dkr,|d}n>|dkr@dj|Ž}n*dj|dd…Ž}|dd…=d  |¡|}td |||rzd nd |dkrˆd nd|fƒ‚dS)Ncsg|]}|ˆkrt|ƒ‘qSr )r:)rWr@)r(r r r¢ sz&_missing_arguments..r‘rrÕz {} and {}z , {} and {}éþÿÿÿz, z*%s() missing %i required %s argument%s: %sÚ positionalz keyword-onlyrÖr¬)rrrtr—rŒ)Úf_nameZargnamesÚposr(rRÚmissingr¬Útailr )r(r Ú_missing_argumentss    rUc 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|]}|ˆkr|‘qSr r )rWrB)r(r r r¢sz_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)rrr�rŒ) rQrZkwonlyrZdefcountZgivenr(ZatleastZ kwonly_givenZpluralr0Z kwonly_sigÚmsgr )r(r Ú _too_manys$    rWcOs4|d}|dd…}t|ƒ}|\}}}}} } } |j} i} t|ƒrV|jdk rV|jf|}t|ƒ}t|ƒ}|rrt|ƒnd}t||ƒ}x t|ƒD]}||| ||<qŠW|rºt||d…ƒ| |<t|| ƒ}|rÒi| |<xd|  ¡D]X\}}||k�r|�st d| |fƒ‚|| ||<qÜ|| k�r,t d| |fƒ‚|| |<qÜW||k�r\|�s\t | || |||| ƒ||k�rØ|d||…}x&|D]}|| k�r|t | |d| ƒ�q|Wx8t |||d…ƒD] \}}|| k�r´||| |<�q´Wd}x>| D]6}|| k�râ| �r|| k�r| || |<n|d7}�qâW|�r0t | | d| ƒ| S)zíGet the mapping of arguments to values. A dict is returned, with keys the function argument names (including the names of the * and ** arguments, if any), and values the respective bound values from 'positional' and 'named'.rr‘Nz*%s() got an unexpected keyword argument %rz(%s() got multiple values for argument %rTF)rr…rr†rrr”r•r^rHr=rŒrWrUrE)Zfunc_and_positionalZnamedrurPrJrrr rr rrrQZ arg2valueZnum_posZnum_argsZ num_defaultsÚnršZpossible_kwargsÚkwrAZreqrBrSÚkwargr r r Ú getcallargs-sd                 r[Ú ClosureVarsz"nonlocals globals builtins unboundc Cst|ƒr|j}t|ƒs$td |¡ƒ‚|j}|jdkr:i}ndd„t|j|jƒDƒ}|j }|  dt j ¡}t |ƒrt|j }i}i}tƒ}xn|jD]d}|dkr˜qŠy||||<WqŠtk rìy||||<Wntk ræ| |¡YnXYqŠXqŠWt||||ƒ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. z{!r} is not a Python functionNcSsi|]\}}|j|“qSr )Ú cell_contents)rWÚvarZcellr r r ú ‚sz"getclosurevars..Ú __builtins__)ÚNoneÚTrueÚFalse)rrƒrrŒrtrÚ __closure__ÚzipÚ co_freevarsÚ __globals__r~r¿r<r rHÚco_namesÚKeyErrorrMr\) ruÚcodeZ nonlocal_varsZ global_nsZ builtin_nsZ global_varsZ builtin_varsZ unbound_namesr@r r r Úgetclosurevarsms8   rkÚ Tracebackz+filename lineno function code_context indexr‘cCsÚt|ƒr|j}|j}n|j}t|ƒs2td |¡ƒ‚t|ƒp@t|ƒ}|dkr¾|d|d}yt |ƒ\}}Wnt k r†d}}YqÆXt 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‘rÕN)r.Ú tb_linenorœÚf_linenor0rŒrtr¹r rÔrÍÚmaxr”rrrlr�rú)r7ÚcontextÚlinenor­rÙr˜rÓÚindexr r r Ú getframeinfo¤s$rscCs|jS)zCGet the line number from a frame object, allowing for optimization.)rn)r7r r r Ú getlinenoÄsrtÚ FrameInfo)r7cCs6g}x,|r0|ft||ƒ}| t|Ž¡|j}qW|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.)rsrKruÚf_back)r7rpÚ framelistÚ frameinfor r r ÚgetouterframesËs  rycCs8g}x.|r2|jft||ƒ}| t|Ž¡|j}qW|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œrsrKruÚtb_next)Útbrprwrxr r r Úgetinnerframes×s  r|cCsttdƒrt d¡SdS)z?Return the frame of the caller or None if this is not possible.Ú _getframer‘N)rrpr}r r r r Ú currentframeãsr~cCstt d¡|ƒS)z@Return a list of records for the stack above the caller's frame.r‘)ryrpr})rpr r r ÚstackçsrcCstt ¡d|ƒS)zCReturn a list of records for the stack below the current exception.rÕ)r|rpÚexc_info)rpr r r Útraceësr�cCstjd |¡S)Nrj)r r<r)Úklassr r r Ú_static_getmroôsrƒcCs8i}yt |d¡}Wntk r(YnXt ||t¡S)Nr<)rÚ__getattribute__rLÚdictr~Ú _sentinel)rgÚattrZ instance_dictr r r Ú_check_instance÷s rˆc CsFx@t|ƒD]4}tt|ƒƒtkr y |j|Stk r<Yq Xq WtS)N)rƒÚ_shadowed_dictr r†r<ri)r‚r‡Úentryr r r Ú _check_classs  r‹cCs&y t|ƒWntk r dSXdS)NFT)rƒrŒ)rgr r r Ú_is_type s  rŒc Csntjd}x^t|ƒD]R}y| |¡d}Wntk r>YqXt|ƒtjkrb|jdkrb|j|ks|SqWt S)Nr<) r r<rƒrrirrr…rZr†)r‚Ú dict_attrrŠZ class_dictr r r r‰s   r‰c Cst}t|ƒs>t|ƒ}t|ƒ}|tks2t|ƒtjkrBt||ƒ}n|}t||ƒ}|tk r„|tk r„tt|ƒdƒtk r„tt|ƒdƒtk r„|S|tk r�|S|tk rœ|S||krêxDtt|ƒƒD]4}tt|ƒƒtkr²y |j |St k räYq²Xq²W|tk rö|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ƒr<rirL)rgr‡r+Zinstance_resultr‚r�Z klass_resultrŠr r r Úgetattr_statics6     rŽÚ GEN_CREATEDÚ GEN_RUNNINGÚ GEN_SUSPENDEDÚ GEN_CLOSEDcCs,|jr tS|jdkrtS|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 ÚgetgeneratorstateSs   r—cCs:t|ƒstd |¡ƒ‚t|ddƒ}|dk r2|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)r%rŒrtr>r”r6)r–r7r r r Úgetgeneratorlocalses  r˜Ú CORO_CREATEDÚ CORO_RUNNINGÚCORO_SUSPENDEDÚ CORO_CLOSEDcCs,|jr tS|jdkrtS|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ƒ}|dk r|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)r>r6)rŸr7r r r Úgetcoroutinelocals�s r¡Ú from_bytescCs6yt||ƒ}Wntk r"dSXt|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)r>rLrÚ_NonUserDefinedCallables)rXZ method_nameZmethr r r Ú"_signature_get_user_defined_method«s  r¤c Csœ|j}t| ¡ƒ}|jpd}|jp$i}|r2||}y|j||Ž}Wn6tk rx}zd |¡} t| ƒ|‚Wdd}~XYnXd} �x | ¡D�]ü\} } y|j | } Wnt k r¶YnlX| j t krÎ|  | ¡qŠ| j tk�r| |krød} | j| d�|| <n|  | j¡qŠ| j tk�r"| j| d�|| <| rŠ| j tk�rV|| jtd�}||| <| | ¡qŠ| j ttfk�rr| | ¡qŠ| j tkrŠ|  | j¡qŠW|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+)rh)r')r'rr=rÚkeywordsÚ bind_partialrŒrtrsÚ argumentsrirhr)r–r*r;r@r-Ú move_to_endr.r,r()Ú wrapped_sigÚpartialZ extra_argsZ old_paramsÚ new_paramsZ partial_argsZpartial_keywordsZbar1rVZtransform_to_kwonlyÚ param_namer4Z arg_valueZ new_paramr r r Ú_signature_get_partial»sL              r­cCslt|j ¡ƒ}|r$|djttfkr,tdƒ‚|dj}|ttfkrP|dd…}n|t k r`tdƒ‚|j |d�S)zWPrivate helper to transform signatures for unbound functions to bound methods. rzinvalid method signaturer‘Nzinvalid argument type)r') r^r'r(rhr.r-rsr*r)r,r;)r0Úparamsrhr r r Ú_signature_bound_methods  r¯cCs&t|ƒp$t|ƒp$t|tƒp$|ttfkS)zxPrivate helper to test if `obj` is a callable that might support Argument Clinic's __text_signature__ protocol. )r4rrr£r r)rgr r r Ú_signature_is_builtin!s r°cCs”t|ƒrt|ƒrdSt|ddƒ}t|ddƒ}t|dtƒ}t|dtƒ}t|ddƒ}t|tjƒo’t|tƒo’|dksxt|tƒo’|dksŠ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__) Úcallabler r>Ú_voidrrr1r�r^r…)rgr@rjrr3r2r r r Ú_signature_is_functionlike-s       r¶cCs<| d¡}|dkr| d¡}| d¡}| d¡}|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. ú,r|rëú:r@rÕ)Úfind)rJrRZcposr r r Ú_signature_get_bound_paramFs    rºcCs$|s|ddfSd}d}dd„| d¡Dƒ}t|ƒj}t |¡}d}d}g}|j} d} tj} tj} t|ƒ} x¦|D]ž} | j | j }}|| kr¾|dkr¨|ršd}qnd}| d 7} qn|d kr¾d}| d }qn|| krÔ|d krÔ| }qn|rôd}|| krì|d ksô| d ƒ| |ƒ|dkrn| dƒqnWd  |¡}|||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)rWÚlr r r r¢psz6_signature_strip_non_python_syntax..r�Frr·Tr‘ú/ú$rëz, ú rÖ) r�rõrörìrKròÚOPÚ ERRORTOKENÚnextr Ústringr—)Ú signatureÚself_parameterÚlast_positional_onlyr˜r–Z token_streamZ delayed_commaZskip_next_commarArMZcurrent_parameterrÁrÂÚtr rÄÚclean_signaturer r r Ú"_signature_strip_non_python_syntax]sP       rÊTc shddl‰|j‰t|ƒ\}}}d|d}yˆ |¡}Wntk rNd}YnXt|ˆjƒsjtd |¡ƒ‚|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�}|dk �rJˆj‰nˆj‰x.parse_namec sªyt|ˆƒ}Wn>tk rLyt|ˆƒ}Wntk rFtƒ‚YnXYnXt|tƒrbˆ |¡St|ttfƒrzˆ |¡St|t ƒrŽˆ  |¡S|dkr ˆ  |¡Stƒ‚dS)N)TFN) ÚevalÚ NameErrorÚ RuntimeErrorrr�ZStrÚintÚfloatZNumÚbytesZBytesZ NameConstant)r¬rA)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}|}x"t|ˆjƒr*| |j¡|j}q Wt|ˆjƒs>tƒ‚| |j¡d t |ƒ¡}ˆ|ƒS)Nr{) rrVrKr‡rAÚNamerÐror—Úreversed)rŠrËÚarXrA)rÌrÖr r Úvisit_Attributeås    z<_signature_fromstr..RewriteSymbolics.visit_Attributecst|jˆjƒstƒ‚ˆ|jƒS)N)rZctxZLoadrsro)rŠrË)rÌrÖr r Ú visit_Nameñsz7_signature_fromstr..RewriteSymbolics.visit_NameN)r…rr€rÚrÛr )rÌrÖr r ÚRewriteSymbolicsäs rÜcsŠˆ|ƒ}|ˆkrdS|rp|tk rpyˆƒ |¡}ˆ |¡}Wntk rRˆ}YnX|ˆkr`dS|ˆk rl|n|}ˆ ˆ|ˆ|ˆd�¡dS)N)r+r/)Ú_emptyZvisitZ literal_evalrsrK)Z name_nodeZ default_noder+r@Úo)Ú ParameterrÜrÌr&Úinvalidrhr'rÍr r Úpös   z_signature_fromstr..p)Ú fillvaluer†)rh)r%)'rÌÚ_parameter_clsrÊÚparseÚ SyntaxErrorrZModulersrtZbodyr&rr>rpr}r~r<rÁZNodeTransformerrØrrÚ itertoolsÚ zip_longestÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORDrErZvarargÚVAR_POSITIONALÚ KEYWORD_ONLYrer Z kw_defaultsrZÚ VAR_KEYWORDr r–r;)rXrgr¬r rÉrÆrÇZprogramrŸrmZ module_namerárrrõršr@r+Ú_selfZ self_isboundZ self_ismoduler ) rßrÜrÌr&ràrhrÔr'rÍrÕrÖr Ú_signature_fromstr¥sl                  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Œrtr>rsrî)rXrur r¬r r r Ú_signature_from_builtin5s rðc Csúd}t|ƒs(t|ƒrd}ntd |¡ƒ‚|j}|j}|j}|j}t|d|…ƒ}|j }||||…} |j } |j } |j } | r†t | ƒ} nd} g}|| }x4|d|…D]$}|  |t¡}| |||td�¡q¤WxBt||d…ƒD].\}}|  |t¡}| |||t| |d�¡qÞW|jt@�rH|||}|  |t¡}| |||td�¡xJ| D]B}t}| dk �rl|  |t¡}|  |t¡}| |||t|d�¡�qNW|jt@�rä||}|jt@�r¼|d7}||}|  |t¡}| |||td�¡|||  d t¡|d �S) zCPrivate helper: constructs Signature for the given python function.FTz{!r} is not a Python functionNr)r/rh)r/rhr+r‘r")r%Ú__validate_parameters__)rr¶rŒrtrãrr r r^rr³r±r²rrr~rÝrKr*rErrr,r-rr.)rXruZis_duck_functionrßZ func_codeZ pos_countZ arg_namesrPZkeyword_only_countZ keyword_onlyr2rr3Zpos_default_countr'Znon_default_countr@r/Úoffsetr+rrr r r Ú_signature_from_functionEsj                     ró)rr c CsŠt|ƒstd |¡ƒ‚t|tjƒrDt|j|||d�}|r@t|ƒS|S|rtt |dd„d�}t|tjƒrtt||||d�Sy |j }Wnt k r’Yn&X|dk r¸t|t ƒs´td |¡ƒ‚|Sy |j }Wnt k rÖYnvXt|tjƒ�rLt|j|||d�}t||dƒ}t|j ¡ƒd }|jtjk�r(|St|j ¡ƒ}|f|} |j| d �St|ƒ�s`t|ƒ�rjt||ƒSt|ƒ�r‚t|||d �St|tjƒ�r¬t|j|||d�}t||ƒSd}t|tƒ�rÊt t|ƒd ƒ} | dk �ræt| |||d�}nJt |d ƒ} | dk �r t| |||d�}n$t |dƒ} | dk �r0t| |||d�}|dk�r.)rkNz1unexpected object {!r} in __signature__ attribute)Nr)r')r Ú__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Œrtrrrr#rƒr¯rvrôrLr$Ú_partialmethodÚ functoolsÚ partialmethodrur­r^r'r(rhrßrêr;rr¶rór°rðrªr r¤rjrïrîrårröÚ from_callablersr£r3)rgrr r!r0rùr©Zfirst_wrapped_paramZ sig_paramsr«ZcallÚnewZinitrBZtext_sigr1rVr r r r#–sæ                              r#c@seZdZdZdS)rµz1A private marker - used in Parameter & Signature.N)r…rr€r„r r r r rµ_ srµc@seZdZdZdS)rÝz6Marker object for Signature.empty and Parameter.empty.N)r…rr€r„r r r r rÝc srÝc@s(eZdZdZdZdZdZdZdd„ZdS) Ú_ParameterKindrr‘rÕéécCs|jS)N)Ú_name_)rŠr r r Ú__str__n sz_ParameterKind.__str__N) r…rr€rèrérêrërìrr r r r rüg s rüzpositional-onlyzpositional or keywordzvariadic positionalz keyword-onlyzvariadic 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Ú _annotation)r+r/cCs yt|ƒ|_Wn$tk r2td|›d�ƒ‚YnX|tk rf|jttfkrfd}| t|jƒ¡}t|ƒ‚||_||_ |tkr‚tdƒ‚t |t ƒs¤d t |ƒj ¡}t|ƒ‚|ddkrþ|dd… ¡rþ|jtkræd }| t|jƒ¡}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)rürrsrÝr,r.rtÚ_get_paramkind_descrrrrr�r r…rŒÚisdigitr*r)Ú isidentifierr)rŠr@rhr+r/rVr r r rå£ s4   zParameter.__init__cCs t|ƒ|j|jf|j|jdœfS)N)rr)r rrrr)rŠr r r Ú __reduce__Ë s zParameter.__reduce__cCs|d|_|d|_dS)Nrr)rr)rŠÚstater r r Ú __setstate__Ñ s zParameter.__setstate__cCs|jS)N)r)rŠr r r r@Õ szParameter.namecCs|jS)N)r)rŠr r r r+Ù szParameter.defaultcCs|jS)N)r)rŠr r r r/Ý szParameter.annotationcCs|jS)N)r)rŠr r r rhá szParameter.kind)r@rhr/r+cCsL|tkr|j}|tkr|j}|tkr*|j}|tkr8|j}t|ƒ||||d�S)z+Creates a customized copy of the Parameter.)r+r/)rµrrrrr )rŠr@rhr/r+r r r r;å szParameter.replacecCsˆ|j}|j}|jtk r(d |t|jƒ¡}|jtk rb|jtk rPd |t|jƒ¡}nd |t|jƒ¡}|tkrtd|}n|t kr„d|}|S)Nz{}: {}z{} = {}z{}={}r?z**) rhrrrÝrtr<rr:r,r.)rŠrhÚ formattedr r r r÷ s     zParameter.__str__cCsd |jj|¡S)Nz <{} "{}">)rtr‡r…)rŠr r r Ú__repr__ szParameter.__repr__cCst|j|j|j|jfƒS)N)Úhashr@rhr/r+)rŠr r r Ú__hash__ szParameter.__hash__cCsJ||kr dSt|tƒstS|j|jkoH|j|jkoH|j|jkoH|j|jkS)NT)rrßÚNotImplementedrrrr)rŠÚotherr r r Ú__eq__ s    zParameter.__eq__N)r…rr€r„Ú __slots__r)rèr*rér,rêr-rër.rìrÝr&rårr r[r@r+r/rhrµr;rr rrr r r r r߃ s*(    rßc@sheZdZdZdZdd„Zedd„ƒZedd„ƒZed d „ƒZ d d „Z d d„Z dd„Z dd„Z dd„ZdS)ÚBoundArgumentsaResult of `Signature.bind` call. Holds the mapping of arguments to the function's parameters. Has the following public attributes: * arguments : OrderedDict 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||_||_dS)N)r§r)rŠrÅr§r r r rå1 szBoundArguments.__init__cCs|jS)N)r)rŠr r r rÅ5 szBoundArguments.signaturec Cs|g}xn|jj ¡D]^\}}|jttfkr*Py|j|}Wntk rNPYqX|jtkrf|  |¡q|  |¡qWt |ƒS)N) rr'r=rhr.r-r§rir,ÚextendrKr^)rŠrr¬r4rBr r r r9 s  zBoundArguments.argsc Cs–i}d}xˆ|jj ¡D]x\}}|sF|jttfkr6d}n||jkrFd}q|sLqy|j|}Wntk rnYqX|jtkr†| |¡q|||<qW|S)NFT) rr'r=rhr.r-r§riÚupdate)rŠÚkwargsZkwargs_startedr¬r4rBr r r rP s&    zBoundArguments.kwargsc Cs |j}g}x†|jj ¡D]v\}}y| |||f¡Wqtk rŒ|jtk rX|j}n"|jt krhd}n|jt krxi}nw| ||f¡YqXqWt |ƒ|_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§rr'r=rKrir+rÝrhr,r.r)rŠr§Z new_argumentsr@r4Úvalr r r Úapply_defaultsn s    zBoundArguments.apply_defaultscCs2||kr dSt|tƒstS|j|jko0|j|jkS)NT)rrrrÅr§)rŠrr r r rŠ s   zBoundArguments.__eq__cCs|d|_|d|_dS)Nrr§)rr§)rŠr r r r r ’ s zBoundArguments.__setstate__cCs|j|jdœS)N)rr§)rr§)rŠr r r Ú __getstate__– szBoundArguments.__getstate__cCsDg}x(|j ¡D]\}}| d ||¡¡qWd |jjd |¡¡S)Nz{}={!r}z <{} ({})>z, )r§r=rKrtr‡r…r—)rŠrrBrAr r r r ™ szBoundArguments.__repr__N)r…rr€r„rrår[rÅrrrrr rr r r r r r s   rc@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)-r$aA 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Ú _parametersNT)r%rñc Csö|dkrtƒ}nÐ|rÎtƒ}t}d}x¼t|ƒD]œ\}}|j} |j} | |krjd} |  t|ƒt| ƒ¡} t| ƒ‚n| |krzd}| }| ttfkr¦|j t kr¢|r¦d} t| ƒ‚nd}| |krÀd | ¡} t| ƒ‚||| <q,Wntdd„|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|fVqdS)N)r@)rWr4r r r rYï sz%Signature.__init__..)rr)rErhr@rtrrsr*r+rÝrÚMappingProxyTyperr) rŠr'r%rñr®Ztop_kindZ kind_defaultsÚidxr4rhr@rVr 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()rÕ)r)rrrró)rXrur 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()rÕ)r)rrrrð)rXrur r r Ú from_builtin s zSignature.from_builtin)Úfollow_wrappedcCst|||d�S)z3Constructs Signature for the given callable object.)r!r)r#)rXrgr"r r r rú szSignature.from_callablecCs|jS)N)r)rŠr r r r' szSignature.parameterscCs|jS)N)r)rŠr r r r% szSignature.return_annotation)r'r%cCs0|tkr|j ¡}|tkr |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µr'r(rr )rŠr'r%r r r r; s  zSignature.replacecCs8tdd„|j ¡Dƒƒ}dd„|j ¡Dƒ}|||jfS)Ncss|]}|jtkr|VqdS)N)rhr-)rWr4r r r rY+ sz(Signature._hash_basis..cSsi|]}|jtkr||j“qSr )rhr-r@)rWr4r r r r_. sz)Signature._hash_basis..)r^r'r(r%)rŠr®Ú kwo_paramsr r r Ú _hash_basis* szSignature._hash_basiscCs(| ¡\}}}t| ¡ƒ}t|||fƒS)N)r$Ú frozensetr(r )rŠr®r#r%r r r r3 s zSignature.__hash__cCs*||kr dSt|tƒstS| ¡| ¡kS)NT)rr$rr$)rŠrr r r r8 s  zSignature.__eq__F)rªc Csžtƒ}t|j ¡ƒ}d}t|ƒ}�xxy t|ƒ}WnÈtk røy t|ƒ} Wntk rbPYn’X| jtkrrPn‚| j|kr¬| jt kr¢d} | j | jd�} t | ƒd‚| f}PnH| jt ksÀ| j tk rÊ| f}Pn*|rØ| f}Pnd} | j | jd�} t | ƒd‚Yq$Xy t|ƒ} Wn tk �r&t dƒd‚Yq$X| jt tfk�rBt dƒd‚| jtk�rn|g} |  |¡t| ƒ|| j<P| j|k�rŽt dj | jd�ƒd‚||| j<q$Wd} x¼t ||¡D]¬} | jt k�rÆ| } �q®| jtk�rÖ�q®| j} y| | ¡}WnFtk �r0|�s,| jtk�r,| j tk�r,t dj | d�ƒd‚Yn(X| jt k�rPt dj | jd�ƒ‚||| <�q®W|�r’| dk �rz||| 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)rBNz$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})rrõr'r(rÃÚ StopIterationrhr,r@r)rtrŒr.r+rÝr-rr^ræÚchainr–riÚ_bound_arguments_cls)rŠrrrªr§r'Z parameters_exZarg_valsZarg_valr4rVr(Z kwargs_paramr¬r r r Ú_bind? s”                   zSignature._bindcOs|d |dd…|¡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. rr‘N)r))rrr r r Úbind szSignature.bindcOs|dj|dd…|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. rr‘NT)rª)r))rrr r r r¦É szSignature.bind_partialcCs t|ƒt|j ¡ƒfd|jifS)Nr)r r^rr(r)rŠr r r rÐ szSignature.__reduce__cCs|d|_dS)Nr)r)rŠr r r r r Õ szSignature.__setstate__cCsd |jj|¡S)Nz<{} {}>)rtr‡r…)rŠr r r r Ø szSignature.__repr__c CsÄg}d}d}xr|j ¡D]d}t|ƒ}|j}|tkr8d}n|rJ| d¡d}|tkrXd}n|tkrr|rr| d¡d}| |¡qW|rŽ| d¡d d  |¡¡}|j t k rÀt |j ƒ}|d |¡7}|S)NFTr¾r?z({})z, z -> {}) r'r(r�rhr)rKr,r-rtr—r%rÝr<) rŠreZrender_pos_only_separatorZrender_kw_only_separatorr4r rhZrenderedZannor r r rÛ s0      zSignature.__str__)N)r…rr€r„rrßrãrr(rÝr&rårcr r!rúr[r'r%rµr;r$rrr)r*r¦rr r rr r r r r$  s26    r$)r"cCstj||d�S)z/Get a signature object for the passed callable.)r")r$rú)rgr"r r r rÅ srÅc CsÌddl}ddl}| ¡}|jddd�|jdddd d �| ¡}|j}| d ¡\}}}y| |¡}} WnNtk r¶} z0d   |t | ƒj | ¡} t | t jd �t  d¡Wdd} ~ XYnX|râ| d¡} | }x| D]} t|| ƒ}qÐW| j t jk�rt dt jd �t  d¡|j�r¼t d  |¡ƒt d  t| ƒ¡ƒt d  | j¡ƒ|| k�r|t d  t| jƒ¡ƒt| dƒ�r²t d  | j¡ƒn6yt|ƒ\}}Wntk �r¢YnXt d  |¡ƒt dƒn t t|ƒƒdS)z6 Logic for inspecting an object given at command line rNrzCThe 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ÄrÕr{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_moduler_rtr r…ÚprintrpÚstderrÚexitr�r>Úbuiltin_module_namesZdetailsr¹Ú __cached__r:r®rr.rÔrü)r/r¦ÚparserrÚtargetZmod_nameZ has_attrsZattrsrgrŸrfrVÚpartsÚpartÚ__rqr r r Ú_main sV      r?r¾)N)N)N)F)N)r‘)r‘)r‘)r‘)r‘)r )T)T)­r„Ú __author__r*ÚdisZcollections.abcr)ÚenumÚimportlib.machineryr¦rær·r£rÏrprìròrrrør¿ÚoperatorrrrÚglobalsZmod_dictZCOMPILER_FLAG_NAMESr=rSrTr9r r rrrrrrrrr r!r#r%r'r,r.r0r2r4r5rCrUrVrirGrvrzr‚r‹r�rŽr r«r¹r½rÀrÂr¶rÔrÜr_rÝrÞrùrûrürýrrr rrrrrr5r8r<r>r�rKrNrUrWr[r\rkrlrsrtÚ_fieldsruryr|r~rr�rr†rƒrˆr‹rŒr‰rŽr�r�r‘r’r—r˜r™ršr›rœr r¡r rõZ_WrapperDescriptorÚallZ_MethodWrapperrÑr<Z_ClassMethodWrapperr3r£r¤r­r¯r°r¶rºrÊrîrðrór#rµrÝÚIntEnumrürèr)rér*rêr,rër-rìr.Z_PARAM_NAME_MAPPINGÚ __getitem__rrßrr$rÅr?r…r r r r Úsb            , t$ ;   .I-7      [   4> 5        0   L H  RH k: