QftdZdZgdZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZmZddlmZeZej@jCD] \Z"Z#e"ed e#z<["[#[d Z$ddd d d Z%dZ&dZ'dZ(dZ)dZ*e+edrdZ,ndZ,e+edrdZ-ndZ-dZ.dZ/dZ0e1Z2dZ3dZ4dZ5dZ6d Z7d!Z8d"Z9d#Z:d$Z;d%Zd(Z?d)Z@d*ZAd+ZBdd,ZCdd-ZDed.d/ZEd0ZFd1ZGdd2d3ZHd4ZId5ZJd6ZKd7ZLd8ZMd9ZNd:ZOd;ZPdd<ZQiZRiZSdd=ZTGd>d?eUZVGd@dAejZXdBZYdCZZGdDdEeUZ[GdFdGZ\dHZ]dIZ^dJZ_dKZ`ddLZaedMdNZbdOZcedPdQZddRZeedSdTZfdUZgddVZhdWZiejdXdYdZfd[Zkd\Zld]Zmd^Zned_d`ZodaZpedbdcZqGdddeeqZrdfZsdgZtddhZudiZvedjdkerjzZxGdldmexZyddnZzddoZ{dpZ|ddqZ}ddrZ~e1ZejdsjZejdtjZduZdvZejdwZdxZefdyZdzZd{Zd|Zd}Zd~ZdZdZdZdZdZdZdZdZdZdZdZdZdZej:ej<ej>ej@fZdZddZdZdZdZdZddZddZ ddZdZddddd ddZGddZGddZGddej^ZejbZejfZejjZejnZejrZGddZGddZGddZdddd ddZGddej~ZdZedk(reyy)aFGet 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 get_annotations() - safely compute an object's annotations )zKa-Ping Yee z'Yury Selivanov )h AGEN_CLOSED AGEN_CREATED AGEN_RUNNINGAGEN_SUSPENDEDArgInfo Arguments Attribute BlockFinderBoundArguments BufferFlags CORO_CLOSED CORO_CREATED CORO_RUNNINGCORO_SUSPENDEDCO_ASYNC_GENERATOR CO_COROUTINE CO_GENERATORCO_ITERABLE_COROUTINE CO_NESTED CO_NEWLOCALS CO_NOFREE CO_OPTIMIZED CO_VARARGSCO_VARKEYWORDSClassFoundException ClosureVars EndOfBlock FrameInfo FullArgSpec GEN_CLOSED GEN_CREATED GEN_RUNNING GEN_SUSPENDED Parameter SignatureTPFLAGS_IS_ABSTRACT Tracebackclassify_class_attrscleandoc currentframe findsourceformatannotationformatannotationrelativetoformatargvaluesget_annotations getabsfilegetargs getargvaluesgetasyncgenlocalsgetasyncgenstategetattr_staticgetblock getcallargs getclasstreegetclosurevars getcommentsgetcoroutinelocalsgetcoroutinestategetdocgetfile getframeinfogetfullargspecgetgeneratorlocalsgetgeneratorstategetinnerframes getlineno getmembersgetmembers_static getmodule getmodulenamegetmrogetouterframes getsource getsourcefilegetsourcelines indentsize isabstract isasyncgenisasyncgenfunction isawaitable isbuiltinisclassiscode iscoroutineiscoroutinefunctionisdatadescriptorisframe isfunction isgeneratorisgeneratorfunctionisgetsetdescriptorismemberdescriptorismethodismethoddescriptorismethodwrapperismodule isroutine istracebackmarkcoroutinefunction signaturestacktraceunwrapwalktreeN) iskeyword) attrgetter) namedtuple OrderedDict)refCO_iFglobalslocalseval_strc rt|trt|dd}|r;t|dr/|j dd}t|t j rd}nd}d}t|dd}|r/tjj |d}|r t|dd}tt|} |} npt|t jrt|dd}t|d}d} d} n8t|rt|dd}t|dd}d} |} nt|d|iSt|tst|d|siS|s t|S| Z t| d r | j} t| t j"r | j$} A t| dr | j&}||}|| xsi}t|d d x} r| D cic]} | j(| c} |z}|j+D cic]%\} }| t|t,s|n t/|||'}} }|Scc} wcc}} w) aCompute the annotations dict for an object. obj may be a callable, class, or module. Passing in an object of any other type raises TypeError. Returns a dict. get_annotations() returns a new dict every time it's called; calling it twice on the same object will return two different but equivalent dicts. This function handles several details for you: * If eval_str is true, values of type str will be un-stringized using eval(). This is intended for use with stringized annotations ("from __future__ import annotations"). * If obj doesn't have an annotations dict, returns an empty dict. (Functions and methods always have an annotations dict; classes, modules, and other types of callables may not.) * Ignores inherited annotations on classes. If a class doesn't have its own annotations dict, returns an empty dict. * All accesses to object members and dict values are done using getattr() and dict.get() for safety. * Always, always, always returns a freshly-created dict. eval_str controls whether or not values of type str are replaced with the result of calling eval() on those values: * If eval_str is true, eval() is called on values of type str. * If eval_str is false (the default), values of type str are unchanged. globals and locals are passed in to eval(); see the documentation for eval() for more information. If either globals or locals is None, this function may replace that value with a context-specific default, contingent on type(obj): * If obj is a module, globals defaults to obj.__dict__. * If obj is a class, globals defaults to sys.modules[obj.__module__].__dict__ and locals defaults to the obj class namespace. * If obj is a callable, globals defaults to obj.__globals__, although if obj is a wrapped function (using functools.update_wrapper()) it is first unwrapped. __dict__Nget__annotations__ __module__ __globals__z% is not a module, class, or callable.z+.__annotations__ is neither a dict nor None __wrapped____type_params__) isinstancetypegetattrhasattrrwtypesGetSetDescriptorTypesysmodulesdictvars ModuleTypecallable TypeError ValueErrorr{ functoolspartialfuncrz__name__itemsstreval)objrrrsrtobj_dictann obj_globals module_namemodule obj_localsrh type_paramsparamkeyvalue return_values ./opt/alt/python312/lib64/python3.12/inspect.pyr.r.sXZ#t3 D1 %0,,0$7C#u99:C c<6 [[__[$7F%fj$? $s)_  C)) *c,d3c:.   #c,d3c=$7  3'!FGHH { c4 C7"MNOO  Cy v}-++&)"3"34  6= ) ,,K ~!r c#4b99{95@A[E%..%'[AFJ))+(%JCs+eWf1MN%(  B(s H.?*H3c6t|tjS)z&Return true if the object is a module.)r~rrobjects rrara* fe.. //c"t|tS)z%Return true if the object is a class.)r~rrs rrSrS.s fd ##rc6t|tjS)z0Return true if the object is an instance method.)r~r MethodTypers rr^r^2rrct|st|s t|ryt|}t |dxr t |d S)aReturn 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__rSr^rYrrrtps rr_r_6sAv(6*j.@ fB 2y ! @'"i*@&@@rct|st|s t|ryt|}t |dxs t |dS)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__rrs rrWrWJs>v(6*j.@ fB 2y ! >WR%>>rMemberDescriptorTypec6t|tjS)Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.)r~rrrs rr]r]Z &%"<"<==rcy)rFr}rs rr]r]b rrc6t|tjS)Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.)r~rrrs rr\r\krrcy)rFr}rs rr\r\srrc6t|tjS)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)r~r FunctionTypers rrYrYzs fe00 11rct|r|j}t|rtj|}t |s t |syt |jj|zS)zReturn 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__r_unwrap_partialrY_signature_is_functionlikebool__code__co_flags)fflags r_has_code_flagrsY 1+ JJ 1+!!!$A qM7:  ##d* ++rc"t|tS)zReturn 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.)rrrs rr[r[s #| ,,rct|r|j}t|rtj|}t |ddt uS)N_is_coroutine_marker)r^rrrr_is_coroutine_markrs r_has_coroutine_markrsA 1+ JJ 1+!!!$A 1,d 37I IIrcLt|dr |j}t|_|S)zM Decorator to ensure callable is recognised as a coroutine function. r)rrrr)rs rrdrds$tZ }} 2D Krc<t|txs t|S)zReturn true if the object is a coroutine function. Coroutine functions are normally defined with "async def" syntax, but may be marked via markcoroutinefunction. )rrrrs rrVrVs #| , H0CC0HHrc"t|tS)zReturn 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. )rrrs rrPrPs #1 22rc6t|tjS)z7Return true if the object is an asynchronous generator.)r~rAsyncGeneratorTypers rrOrOs fe66 77rc6t|tjS)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)r~r GeneratorTypers rrZrZs fe11 22rc6t|tjS)z)Return true if the object is a coroutine.)r~r CoroutineTypers rrUrUs fe11 22rc t|tjxsht|tjxr&t |j j tzxs$t|tjjS)z?Return true if object can be passed to an ``await`` expression.) r~rrrrgi_coderr collectionsabc Awaitablers rrQrQse vu22 3 : vu22 3 FV^^,,/DDE : v{88 9;rc6t|tjS)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))r~r TracebackTypers rrcrcs fe11 22rc6t|tjS)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)r~r FrameTypers rrXrXs feoo ..rc6t|tjS)aReturn 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)r~rCodeTypers rrTrTs. fenn --rc6t|tjS)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)r~rBuiltinFunctionTypers rrRrR s fe77 88rc6t|tjS)z.Return true if the object is a method wrapper.)r~rMethodWrapperTypers rr`r`s fe55 66rct|xs2t|xs%t|xst|xs t |S)zz_getmembers..`s$q'rr)setdirrSrHrrvrr~rDynamicClassAttributeappendAttributeErroraddsort) r predicategetterresults processednamesmrorkvrrs r _getmembersr9s:GI KEvVn (( MM//1DAq!!U%@%@A Q2) 63'Ei$$ Ie, NNC< ( c)* LL)L* N5    $--' MM#.E   s0A C09C0C?0 C<;C<?D3D32D3c$t||tS)zReturn all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.)rrrrs rrDrDcs vy' 22rc$t||tS)a=Return all members of an object as (name, value) pairs sorted by name without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Optionally, only return members that satisfy a given predicate. Note: this function may not be able to retrieve all members that getmembers can fetch (like dynamically created attributes) and may find members that getmembers can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. )rr4rs rrErEhs vy. 99rrzname kind defining_class objectc ^t|}tt|}td|D}|f|z}||z}t|}|D]]}|jj D]>\}}t |tjs!|j.|j|@_g} t} |D]R} d} d} d}| | vrs | dk(r tdt|| } t| d| } | |vrEd} d}|D]}t|| d}|| us|}|D]} |j|| }|| us|}||} |D]'}| |jvs|j| }| |vr|} n| | | n|}t |t tj"frd}|}nJt |t$tj&frd}|}n%t |t(rd}|}nt+|rd }nd }| jt-| || || j/| U| S#t$rYwxYw#t$rYwxYw) 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. c3>K|]}|ttfvs|ywN)rr).0clss r z'classify_class_attrs..sH7Cc$.GC7sNrvz)__dict__ is special, don't want the proxy __objclass__z static methodz class methodpropertymethoddata)rHrtuplerrvrr~rrfgetrr Exceptionr __getattr__r staticmethodBuiltinMethodType classmethodClassMethodDescriptorTyper rbrr)r rmetamro class_bases all_basesrrrrresultrrhomeclsget_objdict_objlast_clssrch_clssrch_objrkinds rr'r'xsu6 +CT#YGH7HHG&3,Kg%I HEMM'')DAq!U889aff>P Q*FI y  +:%#$OPP!#t,"'>7C+-#G#H$/#*8T4#@#w.'/H%0 %,%'/';';C'FH$w.'/H %, +"*Dt}}$==.')"G  ?  ,g( hu/F/F G H"DC ;0O0O"P Q!DC ( +DC s^DD idGS9: dIJ MC .%$%%  s$H H HH H,+H,c|jS)zHReturn tuple of base classes (including cls) in method resolution order.)__mro__)r s rrHrHs ;;rstopch|}t||i}tj}t|ts~t |drr| ||r |S|j }t|}||vst||k\rtdj||||<t|ts t |drr|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. r{z!wrapper loop when unwrapping {!r}) idrgetrecursionlimitr~rrr{lenrformat)rr&rmemorecursion_limitid_funcs rrhrhs A qE1:D++-Ot$})E  T  K T( tOTo!=@GGJK KW t$})E Krcl|j}t|t|jz S)zBReturn the indent size, in spaces, at the start of a line of text.) expandtabsr*lstrip)lineexplines rrMrMs)ooG w<#gnn./ //rctjj|j}|y|jj dddD]}t ||}t|sy|S)N.)rrrwry __qualname__splitrrS)rr rs r _findclassr9s] ++//$// *C {!!'',Sb1c4 2 3< Jrcrt|r.|jD]}|tus |j}||cSyt |rb|j j}|j}t|r'tt||dd|j ur|}nR|j}nDt|r)|j}t|}|t|||uryt|rR|j}|j}t|r"|jdz|z|jk(r|}n|j}nt|t r4|j"}|j}t|}|t|||urpyt%|s t'|rX|j}|j(}t|||uryt+|r't|dd}t|t,r ||vr||Sy|jD]} t||j}||cSy#t$rYwxYw#t$rY>wxYw)Nrr5 __slots__)rSr$r__doc__rr^rr__self__r __class__rYr9rRr7r~r rr_rWr r]r)rrdocrselfr rslotss r_finddocrB!s s|KKD6!,,C?J }||$$|| DM GD$-z :cll JC..C C||o ;'#t,C7 3|||| DM    #d *c.>.> >C..C C "xx}} ;'#t,C7 C $4S$9|| 3 S ( c "Cd3E%&45=T{"  $%--C ?J  m&d   s# H;H* H'&H'* H65H6c |j}| t|}t |t syt |S#t$rYywxYw#ttf$rYywxYw)zGet 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<rrBrr~rr()rr?s rr<r<_sk nn { 6"C c3  C=   *  s 8 A AAAAc@ |jjd}tj}|ddD]8}t |j }|st ||z }t ||}:|r|dj |d<|tjkr%tdt |D] }|||d||<|r|ds|j|r|ds|r|ds|jd|r|dsdj|S#t$rYywxYw)zClean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed. Nrjr6) r0r8rmaxsizer*r1minrangepopjoin UnicodeError)r?linesmarginr2contentindentis rr(r(rs   &&t, !"ID$++-(GTW,VV,  Qx(E!H CKK 1c%j)eAhvw6G58)E"I IIKE"IE!H IIaLE!Hyy) sD DDct|r3t|ddr |jStdj |t |rt |dr\tjj|j}t|ddr |jS|jdk(r tdtdj |t|r |j}t|r |j}t!|r |j"}t%|r |j&}t)|r |j*Stdj t-|j.) z@Work out which source or compiled file an object was defined in.__file__Nz{!r} is a built-in modulery__main__source code not availablez{!r} is a built-in classzVmodule, class, method, function, traceback, frame, or code object was expected, got {})rarrSrr+rSrrrrwryOSErrorr^rrYrrctb_framerXf_coderT co_filenamerr)rrs rr=r=s& 6:t ,?? "3::6BCCv 6< ([[__V%6%67Fvz40&  J.9::299&ABB&6v f~!!! 77=vL))8+ ,,rctjj|}tjj Dcgc]}t | |f}}|j|D]\}}|j|s|d|cSycc}w)z1Return the module name for a given file, or None.N) ospathbasename importlib machinery all_suffixesr*rendswith)r\fnamesuffixsuffixesneglens rrGrGs GG  T "E#,"5"5"B"B"DF"Df+v&"D F MMO" >>& !&> !#  FsB cnt|tjjdd}|tjjddz }t fd|DrAt jjdtjjdzn-t fdtjjDrytjvrSt jjrSt|}t|ddStt|ddddSy)zReturn the filename that can be used to locate an object's source. Return None if no way can be identified to get the source. Nc3@K|]}j|ywrrar sfilenames rr z getsourcefile..s ?)>A8  Q )>rjc3@K|]}j|ywrrhris rr z getsourcefile..s$ 97'(X  q !7rl __loader____spec__loader)r=r^r_DEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESanyr[r\splitextSOURCE_SUFFIXESEXTENSION_SUFFIXES linecachecacheexistsrFr)rall_bytecode_suffixesrrks @rrKrKsvH%//GGJY00LLQOO ?)> ??GG$$X.q1''77:;  9$$77 9 99??" ww~~h vx (Fv|T*6 T2Hd C O Prc|t|xs t|}tjj tjj |S)zReturn 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.)rKr=r[r\normcaseabspath)r _filenames rr/r/s? !&))rfrr generic_visitrJ)r@nodes rvisit_FunctionDefz_ClassFinder.visit_FunctionDefsT $))$ *% 4   rcx|jj|j|jdj |jk(rB|j r|j dj }n |j }|dz}t||j||jjy)Nr5rjrF) rfrrrrKdecorator_listlinenorrrJ)r@r line_numbers rvisit_ClassDefz_ClassFinder.visit_ClassDefs $))$ ==CHHTZZ0 0"""11!4;; "kk  1 K%k2 2 4  rN)rryr7rrvisit_AsyncFunctionDefrr}rrrrs!/ rrc~t|}|rtj|n8t|}|j dr|j ds t dt||}|r!tj||j}ntj|}|s t dt|r|dfSt|rZ|j}dj|}tj|}t!|} |j#|t dt)|r |j*}t-|r |j.}t1|r |j2}t5|r |j6}t9|rkt;|d s t d |j<d z } t?j@d } | dkDr' || } | jE| r || fS| d z } | dkDr'|| fSt d#t$$r}|j&d} || fcYd}~Sd}~wwxYw#tB$r t d wxYw)abReturn the entire source file 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 all the lines in the file and the line number indexes a line in that list. An OSError is raised if the source code cannot be retrieved.<>rUzcould not get source coderjzcould not find class definitionNco_firstlinenoz"could not find function definitionrFz>^(\s*def\s)|(\s*async\s+def\s)|(.*(?? ?$$q(jjZ[Qh 9T{yyd{!8DQhd{ . //9# &&&)K+% % &, 9788 9s*G> H'> H$HH$H$'H<c* t|\}}t|rd}|r |ddddk(rd}|t |kr>||j dvr)|dz}|t |kr||j dvr)|t |kr{||dddk(rog}|}|t |krL||dddk(rA|j ||j|dz}|t |kr ||dddk(rAdj|Syy|dkDrwt||}|dz }|dk\r]||jdddk(rBt|||k(r/||jjg}|dkDr|dz }||jj}|dddk(r]t|||k(rL|g|dd|dz }|dkrn;||jj}|dddk(rt|||k(rL|r4|dj dk(rg|dd|r|dj dk(r|r4|d j dk(rg|d d|r|d j dk(rdj|Syyyy#ttf$rYywxYw) zwGet lines of comments immediately preceding an object's source code. Returns None when source can't be found. Nrjz#!rF)r#rrr6) r*rVrrar*striprr0rKrMr1)rrMrstartcommentsendrPcomments rr9r9rs  ( t U1Xbq\T)15c%j U5\%7%7%9Y%FAIEc%j U5\%7%7%9Y%F 3u: %,r"2c"9HCE "uSz"1~'<c 5 5 78AgE "uSz"1~'<778$ $ #:  E$K(Qh !8c ))+BQ/36 uSz "f ,c --/6689HQwAg*//188:bqkS(Zc -Cv-M$+9HRaL'CQw#Cj335<<>G bqkS(Zc -Cv-M x{002c9!! x{002c9x|113s: " x|113s:778$ $ -78 % Y sJJJc eZdZy)rNrr}rrrrsrrceZdZdZdZdZy)r z@Provide a tokeneater() method to detect the end of a code block.cfd|_d|_d|_d|_d|_d|_d|_y)NrjFrF)rPislambdastartedpassline indecoratorlast body_col0r@s rrzBlockFinder.__init__s4      rcR|js?|js3|dk(rd|_d|_y|dvr|dk(rd|_d|_d|_y|tj k(r8d|_|d|_|jrt|jrd|_yy|jry|tjk(r>|j|jr |d|_ |jdz|_ d|_y|tjk(r*|jdz |_ |jdkrty|tjk(r+|j|d|jk\r |d|_yyy|jdk(r)|tjtjfvrtyy)N@T)defclasslambdarFrjrF)rrrrtokenizeNEWLINErrINDENTrrPDEDENTCOMMENTNL)r@rtokensrowcolerowcolr2s r tokeneaterzBlockFinder.tokeneaters||D$4$4|#' !DM 44H$$(DM#  DM X%% %!DM DI}}  #(  ]]  X__ $~~%$,,!(++/DK DM X__ $++/DK{{a   X%% %~~)gajDNN.J#AJ /K)[[A $x/?/?.M"M #N rN)rryr7r<rrr}rrr r sJ)rr ct} tjt|j}|D]}|j | |d|jS#t tf$rY t$rW}d|jvr|d^}} |j tjg|n#t tf$rYnwxYwYd}~zd}~wwxYw)z@Extract the block of code at the top of the given list of lines. unmatchedN) r rgenerate_tokensiter__next__rrIndentationError SyntaxErrormsgrr)rM blockfindertokens_tokenr_ _token_infos rr5r5s-K ))$u+*>*>?F "K " "F + "+"" ## ( )   aee #  K  "K " "8#3#3 Bk B,-    sA>AC +C 3C !B+*C+B=:C<B==CC ct|}t|\}}t|r |j}t |s$t |r|j jdk(r|dfSt||d|dzfS)aReturn 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.zrjNrF) rhr*rcrWrarXrXco_namer5rrMrs rrLrLsqF^FV$KE46  V]]22j@axde %tax//rc@t|\}}dj|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)rLrKrs rrJrJs !(KE4 775>rcg}|jtdd|D]C}|j||jf||vs%|jt ||||E|S)z-Recursive helper function for getclasstree().ryrr)rrlrrri)classeschildrenparentrcs rriri sbG LLZ j9L: 1;;'( = NN8HQK1= > Nrc.i}g}|D]c}|jr?|jD]/}||vrg||<|||vr||j||s*||vs/LN||vsS|j|e|D]}||vs|j|t||dS)aArrange 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)rrri)runiquerrootsrrs rr7r7sH E  ;;++)')HV$HV,,V$++A.f/ & e^ LLO  LL  E8T **rrzargs, varargs, varkwct|stdj||j}|j}|j }t |d|}t ||||z}||z }d}|jtzr|j|}|dz}d}|jtzr|j|}t||z||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 objectNrF) rTrr+ co_varnames co_argcountco_kwonlyargcountlistrrrr)cornargsnkwargsr kwonlyargsvarargsvarkws rr0r00s ":3::2>?? NNE NNE""G fu DeE%-01J WEG {{Z..'  E {{^#u% TJ& 77rrzGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc  t|ddtd}g}d}d}g}g}i}d} i} |j|j ur|j|d<|j jD]} | j} | j} | tur:|j| | j| j ur| | jfz } n| tur:|j| | j| j urg| | jfz } nV| tur| }nK| tur9|j| | j| j ur| j| | <n | t ur| }| j"| j us| j"|| <!| sd} | sd} t%||z||| || |S#t$r}td|d}~wwxYw)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_chainsskip_bound_argsigclsrtzunsupported callableNr}return)_signature_from_callabler$rrreturn_annotationempty parametersvaluesr"r_POSITIONAL_ONLYrdefault_POSITIONAL_OR_KEYWORD_VAR_POSITIONAL _KEYWORD_ONLY _VAR_KEYWORD annotationr)rsigexrrr posonlyargsr annotationsdefaults kwdefaultsrr"rs rr?r?Ns 8"'t=B6;.705 7 DG EKJKHJ CII- # 5 5 H&&(zzzz # #   t $}}EKK/U]],, + + KK }}EKK/U]],, _ $G ] "   d #}}EKK/#(== 4 \ !E   5;; . % 0 0K -)0   {T)7E8!:{ <.repls;;=D$$Y/ /rz[\w\.]+rr5) rrsubreprr~r GenericAliasrrryr7)r base_modulers rr+r+sz<.(: 0vvj$Z(899*e001:*d#  Z$= =** *$$S()@)@@@  rc,t|ddfd}|S)Nryct|Sr)r+)rrs r_formatannotationz5formatannotationrelativeto.._formatannotations F33r)r)rrrs @rr,r,s V\4 0F4 rc d|zS)N*r}rs rrrssTzrc d|zS)N**r}r"s rrrsTD[rcdt|zS)N=)r)rs rrrs cDK.?rc<|||fd}g} tt|D]} | j||| |r#| j|||||z|r#| j|||||zddj| zdzS)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.c*|||||zSrr})rrs formatarg formatvalues rconvertz formatargvalues..convertsVD\!:::r(, ))rIr*rrK) rrrrsr) formatvarargs formatvarkwr*r+specsrQs rr-r-s$#; E 3t9  WT!W%& ]7+k&/.JJK  ['+fUm*DDE 5! !C ''rc.|Dcgc]}||vst|}}t|}|dk(r|d}n@|dk(rdj|}n+dj|dd}|dd=dj||z}t d|||rd nd |dk(rd nd |fzcc}w) NrFrjrz {} and {}z , {} and {}r-z*%s() missing %i required %s argument%s: %s positional keyword-onlyrrj)rr*r+rKr) f_nameargnamesposrrrmissingrjtails r_missing_argumentsr;s$, CHDF0BT$ZHE C%jG!| !H A K   &#}##U23Z0 "#J IIe t # @W&)l~#qLbc166 77 Ds B Bc vt||z }t|Dcgc] }||vs| c}} |r |dk7} d|fz} n7|rd} d|t|fz} n"t|dk7} tt|} d} | rd} | |dk7rdnd| | dk7rdndfz} td|| | rdnd|| |dk(r | s d fzd fzcc}w) NrFz at least %dTz from %d to %drz7 positional argument%s (and %d keyword-only argument%s)rjz5%s() takes %s positional argument%s but %d%s %s givenwaswere)r*rr)r6rkwonlyrdefcountgivenratleastarg kwonly_givenpluralr  kwonly_sigrs r _too_manyrGs $i("Gv?vv?@LAwj( #d) 44Ta#d)nJGEQJSB $0A$5S2?? K S#R qjU CC DD;A CC DD@s B6B6c Pt|}|\}}}}}} } |j} i} t|r|j|jf|z}t |} t |}|r t |nd}t | |}t |D] }||| ||<|rt||d| |<t||z}|ri| |<|jD]=\}}||vr|st| d||| ||<%|| vrt| d||| |<?| |kDr|st| ||||| | | |krH|d||z }|D]}|| vst| |d| t|||z dD]\}}|| vs ||| |<d}|D]}|| vs| r || vr | || |<|dz }|rt| |d| | S)zGet 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'.Nrjz&() got an unexpected keyword argument z$() got multiple values for argument TrFF)r?rr^r=r*rHrIrrrrrGr; enumerate)rr4namedspecrrrr rkwonlydefaultsrr6 arg2valuenum_posnum_args num_defaultsnrQpossible_kwargskwrreqrCr9kwargs rr6r6s* $ DFJCD'5(J ]]FI~$--3mm% 2 *oG4yH$,3x=!L GXA 1X'] $q'":ab>2 '$+,O  %[[] E _ $!'!-..#(Ie R  ?#R)* * " #'&$ G\I '+H|+,C)#"63i@ X %<%= >?FAs)#!)! #@G  !%>"9#1%#8 % 1   6:ui@ rrz"nonlocals globals builtins unboundct|r |j}t|stdj ||j }|j i}n=t|j|j Dcic]\}}||j}}}|j}|jdtj}t|r |j}i}i}t} |j D]} | dvr || || <t'|||| Scc}}w#t"$r- || || <n #t"$r| j%| YnwxYwY\wxYw)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 function __builtins__)NoneTrueFalse)r^rrYrr+r __closure__zip co_freevars cell_contentsrzrwrrvrarco_namesKeyErrorrr) rcode nonlocal_varsvarcell global_ns builtin_ns global_vars builtin_vars unbound_namesrs rr8r8Fsh~}} d 7>>tDEE ==D  !!1!143C3CD D T $$$ $D    I~x/@/@AJ (( KLEM  , ,  ( )$K   }k#] 447 * ( (%/%5 T" (!!$' ( (s<;D;D E#D,+E,E EE  EE _Tracebackz+filename lineno function code_context indexc*eZdZddfd ZdZxZS)r&N positionsc>t|||||||}||_|Srsuper__new__rn) r rkrfunction code_contextindexrninstancer>s rrrzTraceback.__new__~s)7?3&(LRWX&rcdj|j|j|j|j|j |j S)NzcTraceback(filename={!r}, lineno={!r}, function={!r}, code_context={!r}, index={!r}, positions={!r}))r+rkrrsrtrurnrs r__repr__zTraceback.__repr__s@@@F t{{DMM4;L;L DNNA, -rrryr7rrrx __classcell__r>s@rr&r&}sSW -rr&c^|jj|j}}t||Sr)rWrXtb_lasti_get_code_position)tbrbinstruction_indexs r_get_code_position_from_tbrs( kk00"++ D d$5 66rct|dkry|j}ttj||dzdS)Nrj)NNNNr) co_positionsnext itertoolsislice)rbr positions_gens rr~r~s;1'%%'M    0AQ0FM NNrc t|r$t|}|j}|j}n,|j}t |j |j}|d ||g|dd^}}n|g|^}}|d}t|stdj|t|xs t|}|dkDrM|dz |dzz } t|\}}tdt|t!||z }||||z}|dz |z }ndx}}t%|||j j&||t)j*|S#t"$rdx}}YDwxYw)aGet 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.rjNrFz'{!r} is not a frame or traceback objectrrm)rcr tb_linenorWf_linenor~rXf_lastirXrr+rKr=r*maxrHr*rVr&rdis Positions) rcontextrnrrkrrMrrus rr>r>sq5.u5 &u||U]]C |"F;Yqr]; "/Y/ q\F 5>AHHOPPU#5wu~H{ WaZ' '$U+KE43uc%j7&:;>r _FrameInforc*eZdZddfd ZdZxZS)rNrmc @t ||||||||}||_|Srrp) r rrkrrsrtrurnrvr>s rrrzFrameInfo.__new__s+7?3xrrrnf_back)rr framelisttraceback_info frameinfos rrIrIsX I %eW5H~- IR9Q9QRS   rcg}|rOt||}|jf|z}|jt|d|ji|j }|rO|S)zGet 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.rn)r>rWrrrntb_next)rrrrrs rrBrBs\ I %b'2[[N^3 IR9Q9QRS ZZ rcPttdrtjdSdS)z?Return the frame of the caller or None if this is not possible. _getframerFN)rrrr}rrr)r)s&sK83== BdBrc@ttjd|S)z@Return a list of records for the stack above the caller's frame.rF)rIrr)rs rrfrfs #--*G 44rcbtj}|dn |j}t||S)zCReturn a list of records for the stack below the current exception.N)r exception __traceback__rB)rexcrs rrgrgs+ --/C#"3"3B "g &&rr$rvci} tj|d}tj ||t S#t$rY&wxYwNrv)r__getattribute__rrrw _sentinel)rattr instance_dicts r_check_instancersGM //Z@  88M4 33    s5 AAct|D]<}tt|tus||jvs-|j|cStSr)_static_getmro_shadowed_dictrrrv)klassrentrys r _check_classr sD& $u+ &) 38N>>$' '' rc|D]Z}|}t|}d|vs|d}t|tjur|jdk(r|j |urX|cSt Sr)_get_dunder_dict_of_classrrrrr r) weakref_mro weakref_entryr dunder_dict class_dicts r%_shadowed_dict_from_weakref_mro_tuplersn$ /6  $$Z0J$(B(BB'':5++u4!!% rc\tt|Dcgc] }t|c}Scc}wr)rr make_weakref)rrs rrr$s2 1+9%+@ A+@%,u +@ A  As)ct}t|}tt|vr=|}t|}|tust|tj urt ||}n|}t||}|tur[|turStt|dtur8tt|dtustt|dtur|S|tur|S|tur|S||urStt|D]<}tt|tus||jvs-|j|cS|tur|St|)aRetrieve 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. rrr) rrrrrrrrrvr) rrrinstance_resultobjtyper dict_attr klass_resultrs rr4r41s2 O3iG >'**"5)  " Ou99 9-c48Ot,Li'L ,I \*I 6i G l+Y 7y HD. =YN i'9$ e|#DK0EtE{+y8ENN*~~d++ 1 i  rr r!r"rcz|jrtS|jrtS|jt St S)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. ) gi_runningr! gi_suspendedr"gi_framerr ) generators rrArAjs:! rct|stdj|t|dd}||jj SiS)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 generatorrN)rZrr+rrr)rrs rr@r@|sN y !8?? JKK Iz4 0E !!*** rr rrr cz|jrtS|jrtS|jt St S)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. ) cr_runningr cr_suspendedrcr_framer r ) coroutines rr;r;s:! rc<t|dd}| |jSiS)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.rN)rr)rrs rr:r:s' Iz4 0E ~~ rrrrrcz|jrtS|jrtS|jt St S)a3Get current state of an asynchronous generator object. Possible states are: AGEN_CREATED: Waiting to start execution. AGEN_RUNNING: Currently being executed by the interpreter. AGEN_SUSPENDED: Currently suspended at a yield expression. AGEN_CLOSED: Execution has completed. ) ag_runningr ag_suspendedrag_framerr)agens rr3r3s6   }} rct|st|dt|dd}||jjSiS)z Get the mapping of asynchronous generator local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values.z is not a Python async generatorrN)rOrrrr)rrs rr2r2sH d 4("BCDD D*d +E }}%%% rc|dk(rt||d}n t||d}|t|try|dk7r t ||}|S)zPrivate helper. Checks if ``cls`` has an attribute named ``method_name`` and returns it only if it is a pure python function. rrN)rr4r~_NonUserDefinedCallables_descriptor_get)r  method_namemeths r"_signature_get_user_defined_methodrsU isK.c;5 |z$(@AitS) Krch|j}t|j}|jxsd}|jxsi}|r||z} |j |i|}d} |jD]`\} } |j| } | jtur|j| ;| jtur8| |vrd} | j| || <n|j| j| jt ur| j| || < | s| jtusJ| jtur1|| jt }||| <|j%| | jt t&fvr|j%| 2| jt(usF|j| jc|j|j+S#t $r"}dj|} t| |d}~wwxYw#t"$rYwxYw) zPrivate 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)rr"r)rrnrrkeywords bind_partialrr+r argumentsr"rrJrreplacerrra move_to_endrrr) wrapped_sigr extra_args old_params new_params partial_argspartial_keywordsbar rtransform_to_kwonly param_namer arg_value new_params r_signature_get_partialrs ''JZ--/0J<<%2L''-2!L0 & %[ % %| H7G H  '--/ E# J Z0Izz--z*zz33!11+/'-2]]9]-MJz*NN5::.zz]*).y)I :& ::%55 55zz33&z2:: :N )2 :&&&z2 |<<&&z2.uzz*a0d   **;*;*=  >>q &;BB7Ko2%&   s*G6:H$6 H!?HH!$ H10H1c(t|jj}|r|djtt fvr t d|dj}|ttfvr|dd}n|tur t d|j|S)zWPrivate helper to transform signatures for unbound functions to bound methods. rjzinvalid method signaturerFNzinvalid argument typer) rrrr"rrrrrrr)r paramsr"s r_signature_bound_methodrHs 3>>((* +F VAY^^ m'DD344 !9>>D &(899  &45 5 ;;&; ))rc~t|xs1t|xs$t|txs|tuxs|t uS)zxPrivate helper to test if `obj` is a callable that might support Argument Clinic's __text_signature__ protocol. )rRr_r~rrrrs r_signature_is_builtinrbsI cN ) s # ) s4 5 ) 4K )&=*rct|r t|ryt|dd}t|dd}t|dt}t|dt}t|dd}t |t j xrXt |txrF|duxst |txr.|duxst |txrt |txs|duS)zPrivate 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. FrNr __defaults____kwdefaults__rx) rrSr_voidr~rrrrr)rrrbr rr s rrrps C=GCL 3 D )D 3 D )DsNE2H.6J#0$7K tU^^ , E tS ! E   <He!< E4  ?:j$#? E d , C t0C Grc|s|dfSd}|jdDcgc]}|s|jd}}t|j}t j|}g}|j }d}t j} t j} t|} | jtjk(sJ|D]P} | j| j} } | | k(r | dk(r|dz }| | k(r | dk(r|J|};|| | dk(sI|dRd j|jjdd }||fScc}w) aI Private helper function. Takes a signature in Argument Clinic's extended signature format. Returns a tuple of two things: * that signature re-rendered in standard Python syntax, and * the index of the "self" parameter (generally 0), or None if the function does not have a "self" parameter. NrEasciirj,rF$ r)r8encoderrrrrOP ERRORTOKENrrENCODINGstringrKrr)reself_parameterlrMr token_streamrrcurrent_parameterrrtrrclean_signatures r"_signature_strip_non_python_syntaxrsK $N(1(= C(=1QXXg (=E CU $$I$$Y/L D ++C B!!J \A 66X&& && & vvqxxf 2:}!Q&! BJVs]!) )).N  F cM Hggdm))+33D"=O N **? Ds EETc |jt|\}}d|zdz} tj|}t |tj stdj|jd}gjd}itdd} | r.tjj| d}|r |jtjj!dfdGfd d tj"ffd } t%|j&j(t%|j&j&z} | t%|j&j*z } t-j.t-j0d| |j&j*} j2t5|j&j(| D]\}}| ||j6t5|j&j&| D]\}}| |||j&j8r)j:| |j&j8j<t5|j&j>|j&j@D]\}}| |||j&jBr)jD| |j&jB|\sJtd d}|du}tG|}|r|s|rjIdn$djKj2 } | d<||jS#t$rd}YIwxYw)zdPrivate helper to parse content of '__text_signature__' and return a Signature based on it. zdef fooz: passN"{!r} builtin has invalid signaturerjryct|tjsJ|j t d|jS)Nz'Annotations are not currently supported)r~rrCrr)rs r parse_namez&_signature_fromstr..parse_names5$((( ?? &FG Gxxrc  t|}t|tt t tttdfrtj|St#t$r$ t|}n#t$rtwxYwYvwxYwr) r NameErrorrr~rintfloatbytesrrrConstant)rjr module_dictsys_module_dicts r wrap_valuez&_signature_fromstr..wrap_values !K(E ec3udDJG H<<& & ! !Q0 !   ! !s) A B# A0/B0BBBc(eZdZfdZfdZdZy),_signature_fromstr..RewriteSymbolicsc~g}|}t|tjrB|j|j|j }t|tjrBt|tj st|j|jdjt|}|S)Nr5) r~rrrrrNamerr(rKreversed)r@rarQrrs rvisit_Attributez<_signature_fromstr..RewriteSymbolics.visit_AttributesAAQ . GGQ .a*  HHQTTNHHXa[)Ee$ $rct|jtjs t |j Sr)r~ctxrLoadrr()r@rrs r visit_Namez7_signature_fromstr..RewriteSymbolics.visit_Names,dhh1 l"dgg& &rc|j|j}|j|j}t|tj rt|tj st t|jtjr,t j |j|jzSt|jtjr,t j |j|jz St|jtjr,t j |j|jzSt r) rleftrightr~rrropAddrSubBitOr)r@rrrs r visit_BinOpz8_signature_fromstr..RewriteSymbolics.visit_BinOp s::dii(DJJtzz*EdCLL1E3<<9X  $''377+||DJJ$<==DGGSWW-||DJJ$<==DGGSYY/||DJJ$<== rN)rryr7rrr$)rsrRewriteSymbolicsrs % ' rr%c |}|r4|tur, j|}tj|} j ||y#t$rt dj dwxYw)Nrrr)_emptyrr literal_evalrr+r) name_node default_noderrr#r%rr"rrrs rpz_signature_fromstr..p s)$ L6 ]/177 E **<8 )D$ERS ] !E!L!LS!QRX\\ ]s +A%Br=rr)&_parameter_clsrrrrr~Modulerr+bodyrrrrrwrvrNodeTransformerr*rr r rchainrepeatPOSITIONAL_ONLYr]POSITIONAL_OR_KEYWORDvarargVAR_POSITIONAL KEYWORD_ONLYr kw_defaultsrU VAR_KEYWORDrarJr)r rrjrrrprogramrrrr,total_non_kw_argsrequired_non_kw_argsr rr_self self_isbound self_ismoduler#r%rr"rrrrrs ` @@@@@@@@@r_signature_fromstrrAs""I&H&K#O^/)H4G7# fcjj )=DDSIJJ AAJ OOE FK#|T2Kd3  //Kkk&&(O 3..B,1TTAFF../#affkk2BB,s166??/CCy//6JKQVV__]H  $ $Dqvv118<w $=  * *Dqvv{{H5w $6 vv}}'' !&&--  ! !DQVV..0B0BC g $D vv||$$ !&&,,! zZ.D(   ]n NN1 1 %%9+D+D%EAJqM zSYY 77 sM>> N  N ct|stdj|t|dd}|st dj|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})rrr+rrrA)r rrrjs r_signature_from_builtinrDI sc ! &##)6$<1 1 *D1A >EEdKLL c4N ;;rc d}t|s(t|rd}ntdj|t |dd}|rt ||||S|j }|j} | j} | j} | j} | d| } | j}| | | |z}t||||}|j}|j}|r t|}nd}g}| |z }| }| d|D]H}|rt nt"}|j%|t&}|j)|||||sD|d z}Jt+| |dD]O\}}|rt nt"}|j%|t&}|j)|||||| |sK|d z}Q| j,t.zr<| | |z}|j%|t&}|j)|||t0|D]U}t&}||j%|t&}|j%|t&}|j)|||t2| W| j,t4zrV| |z}| j,t.zr|d z }| |}|j%|t&}|j)|||t6|||j%d t&| S) zCPrivate helper: constructs Signature for the given python function.FTrWrCNrqrj)rr"rF)rr"rrr__validate_parameters__)rYrrr+rrAr.rrrco_posonlyargcountrr.rrr*rrrwr(rrIrrrrrr)r rrrrrsrtis_duck_functionrjr# func_code pos_count arg_names posonly_countr4keyword_only_count keyword_onlyr r rpos_default_countrnon_default_count posonly_leftrr"roffsetrrus r_signature_from_functionrTY s d  %d +# ;BB4HI I*D1A!#tQ??""I I%%I%%I00M:I&J"44Yy3E'EFL!$QYZK  H$$JMJ!$55 L--.#/5K __T62 )DZ)-/ 0  A L /"*->-?"@A #/5K __T62 )DZ)-,4V,<> ?  A LBJ&%778 __T62 )DZ)8: ;  ! nnT62G __T62 )DZ)6,35 6 N*..    * QJE __T62 )DZ)57 8 z!,6!B'7 99rct|r|Stt|dt}|tur|S|||t|S)Nr)rSrrr) descriptorrrws rrr sDz $z"Iy 9C i z3S **r)rrrrrsrtc vtjt||||||}t|st dj |t |tjr!||j}|r t|S|S|r0t|d}t |tjr||S |j}|s|} t |ttfst|r|}t |tr t|||}t |tst dj | |S |j"} t | tj$r|| j&} t)| | d}t+| j,j/d} | j0t2j4ur|St+|j,j/} | r | | dusJ| f| z}|j7| St9|s t;|rt=|||||| St?|rtA||| St |tjr||j&} t)| |St |tBr7tEtC|d }|||StE|d }tE|d}|jFD]F}|'d |jHvr||}|r t|}|cS|/d|jHvs>||cS|jFddD] } |jJ}|st|||cStB|jFvr|jLtNjLur1|jPtNjPur|jStNStUdj |tWtC|d d}|tY||}||StUdj |#t $rYwxYw#t $rY"wxYw#t $rYwxYw)zQPrivate helper function to get signature for arbitrary callable objects. )rrrrrsrrtz{!r} is not a callable objectcRt|dxst|tjS)N __signature__)rr~rrrs rrz*_signature_from_callable.. s''!_*E+C#-a1A1A#B+Crr%Nz1unexpected object {!r} in __signature__ attributerrjr)rrrrsrt)r__call__rrrr6z(no signature found for builtin type {!r}z+callable {!r} is not supported by signature)-rrrrrr+r~rrrrrhrYr$rrAr_partialmethod partialmethodrrrrrr"r#r7rrYrrTrrDrrr$rvrCrrrr from_callablerr4r)rrrrrrsrtr_get_signature_ofr o_sigr\rfirst_wrapped_param sig_paramsrcallnewinitrtext_sigs rrr s7"))*B6K/=(/'-'-)1 3 C=7>>sCDD#u''(  - *3/ /JS!CE c5++ ,%S) ) ?EcIs#34#e#s#(c:c9- &u //J:**  mY%<%< =,M,>,>?K(mWMC"' (>(>(E(E(G"H"K "''9+C+CC "3>>#8#8#:; &+:a=@BA13j@ {{j{99#4S9(7E07QY[ [S!&vs6DF F#y(()'1 %k377#t 2$s)ZH  $T* *0i@1#zBKKD9 #=',!1#6C !jDMM&A(.. KK$D F22.fdHEE!%* s{{ " / v~~-++F33 >EEcJLL d3iT:  "4-D$T* * BII#N OOA    (    ^"  s64 P 6 P- P+ PP P('P(+ P87P8ceZdZdZy)rz1A private marker - used in Parameter & Signature.Nrryr7r<r}rrrrs s;rrceZdZdZy)r(z6Marker object for Signature.empty and Parameter.empty.Nrgr}rrr(r(w s@rr(c,eZdZdZdZdZdZdZdZdZ y) _ParameterKindzpositional-onlyzpositional or keywordzvariadic positionalr5zvariadic keywordcxt|j}tj||}||_||_|Sr)r* __members__r rr_value_ description)r rnrmembers rrrz_ParameterKind.__new__ s4COO$S%(( rc|jSrr"rs r__str__z_ParameterKind.__str__ s yyrN) rryr7r4r5r7r8r:rrrqr}rrrjrj{ s&'O3*N!L$KrrjceZdZdZdZeZeZe Z e Z e ZeZeeddZdZdZedZedZed Zed Zeeeed d Zd ZdZdZdZy)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'cd t||_|turJ|jtt fvr2d}|j |jj}t|||_||_ |tur tdt|ts/dj t|j}t||ddk(rw|ddjrd|jt k7r2d }|j |jj}t|t"|_d j |dd}t%|xr|jt"u}|s|j'std j |||_y#t$rtd|dwxYw) 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 {}rjr5rFzLimplicit arguments must be passed as positional or keyword arguments, not {}z implicit{}z"{!r} is not a valid parameter name)rjrtrr(rrr+rnrurvr~rrrrisdigitrrrk isidentifierrs)r@rr"rrr is_keywords rrzParameter.__init__ s N'-DJ & zzo|<<@jj!7!78 o% % 6>IJ J$$077T 8K8KLCC. 7c>d12h..0 zz33>jj!7!78 o%)DJ&&tABx0Dt_K;K)K T..0AHHNO O M NvdX-KLM M Ns FF/cxt||j|jf|j|jdfS)Nrurv)rrsrtrurvrs r __reduce__zParameter.__reduce__ s8T TZZ(!]] $ 0 023 3rc,|d|_|d|_y)Nrurvr|r@states r __setstate__zParameter.__setstate__ sj)  /rc|jSr)rsrs rrzParameter.name zzrc|jSr)rurs rrzParameter.default s }}rc|jSr)rvrs rrzParameter.annotation rc|jSr)rtrs rr"zParameter.kind rr)rr"rrc|tur |j}|tur |j}|tur |j}|tur |j}t |||||S)z+Creates a customized copy of the Parameter.r')rrsrtrvrur)r@rr"rrs rrzParameter.replace s_ 5=::D 5=::D  ))J e mmGtDz$g*MMrc|j}|j}|jtur%dj |t |j}|j tur]|jtur&dj |t|j }n%dj |t|j }|tk(rd|z}|S|tk(rd|z}|S)Nz{}: {}z{} = {}z{}={}r!r$) r"rsrvr(r+r+rurrr)r@r" formatteds rrqzParameter.__str__ syyJJ    6 )  '78H8H'IKI == &v-%,,YT]]8KL #NN9d4==6IJ ? "iI\ !y(IrcNdj|jj|S)Nz <{} "{}">r+r>rrs rrxzParameter.__repr__ s!!$.."9"94@@rcpt|j|j|j|jfSr)hashrsrtrvrurs r__hash__zParameter.__hash__# s(TZZT-=-=t}}MNNrc ||uryt|tstS|j|jk(xrO|j|jk(xr4|j |j k(xr|j |j k(SNT)r~r#NotImplementedrsrtrurvr@others r__eq__zParameter.__eq__& sv 5=%+! ! ekk)6 ekk)6 /6  E$5$55 7rN)rryr7r<r;rr4rr5rr7rr8rr:r(rrr}rr rrrr"rrrqrxrrr}rrr#r# s*>I.O4-N+L*K E.4)V3 0  $% %N$,AO7rr#cheZdZdZdZdZedZedZedZ dZ dZ d Z d Z d Zy ) r aResult 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__c ||_||_yr)rr)r@rers rrzBoundArguments.__init__D s"#rc|jSr)rrs rrezBoundArguments.signatureH s rc|g}|jjjD]o\}}|jtt fvr t|S |j |}|jtk(r|j|_|j|qt|S#t$rYt|SwxYwr) rrrr"rrrrextendrrar)r@rrrrCs rrzBoundArguments.argsL s!%!;!;!A!A!C JzzlM:: T{ %nnZ0 ::0KK$KK$!"D$T{ T{ sB$$ B;:B;cZi}d}|jjjD]p\}}|s,|jtt fvrd}n||j vrd}4|s7 |j |}|jtk(r|j|l|||<r|S#t$rYwxYw)NFT) rrrr"rrrupdatera)r@kwargskwargs_startedrrrCs rrzBoundArguments.kwargsc s!%!;!;!A!A!C J!::, !>>%)N!7)- ! -nnZ0::-MM#&*-F:&-"D0   s!B B*)B*c|j}g}|jjjD]\}} |j |||ft||_y#t $ra|j tur |j }n,|jturd}n|jturi}nY|j ||fYwxYw)zSet 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) rrrrrrarr(r"rrr)r@r new_argumentsrrvals rapply_defaultszBoundArguments.apply_defaults sNN  ??55;;=KD% 2$$dIdO%<=>m, 2==.--CZZ?2CZZ</C$$dC[1 2sA##AC 7C  C c||uryt|tstS|j|jk(xr|j|jk(Sr)r~r rrerrs rrzBoundArguments.__eq__ sF 5=%0! !%//12%//1 3rc,|d|_|d|_y)Nrrrrrs rrzBoundArguments.__setstate__ s -{+rc4|j|jdS)Nrrrs r __getstate__zBoundArguments.__getstate__ s"ooDNNKKrcg}|jjD]&\}}|jdj||(dj|jj dj |S)Nz{}={!r}z <{} ({})>r-)rrrr+r>rrK)r@rrCrs rrxzBoundArguments.__repr__ s`....0JC KK ((e4 51!!$.."9"9499T?KKrN)rryr7r<r;rr rerrrrrrrxr}rrr r 1 sj ;I$,:-83,LLrr ceZdZdZdZeZeZe Z de dddZ e dddddd Z ed Zed Zeed d ZdZdZdZdddZdZdZdZdZdZdZy)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 _parametersNTrFc| t}n|rt}t}d}|D]}|j}|j} ||kr3d} | j |j |j } t | ||kDr|}|ttfvr#|jtur|rd} t | d}| |vrdj | } t | ||| <ntd|D}tj||_ ||_ y)zConstructs 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}c38K|]}|j|fywrr"r rs rr z%Signature.__init__.. s$QjUejj%%8js)rnrr"rr+rnrrrr(rMappingProxyTyperr) r@rrrGrtop_kind seen_defaultrr"rrs rrzSignature.__init__ s   ]F&$+$ 'E ::D ::Dh("jj)=)=)-)9)9;(o-#' 02HII ==F2+'1&0o 5,0Lv~>EEdK(o-#(F4L?(B%$Qj$QQ 11&9"3rFfollow_wrappedrrrsrtc$t||||||S)z3Constructs Signature for the given callable object.)rrrrrsrt)r)r rrrrrsrts rr]zSignature.from_callable s"(C>L07QY[ [rc|jSr)rrs rrzSignature.parameters rrc|jSrrrs rrzSignature.return_annotation s&&&r)rrc|tur|jj}|tur |j}t |||S)zCreates a customized copy of the Signature. Pass 'parameters' and/or 'return_annotation' arguments to override them in the new copy. r-)rrrrr)r@rrs rrzSignature.replace sJ  //1J  % $ 7 7 tDz*,=? ?rctd|jjD}|jjDcic]"}|jtk(r |j |$}}|||j fScc}w)Nc3FK|]}|jtk7r|ywr)r"rrs rr z(Signature._hash_basis..% s$=*B % m ;*Bs!)rrrr"rrr)r@rr kwo_paramss r _hash_basiszSignature._hash_basis$ s=$//*@*@*B==6:__5K5K5MH5ME+0::+Fjj%'5M Hz4#9#999Hs'A?cx|j\}}}t|j}t|||fSr)r frozensetrr)r@rrrs rrzSignature.__hash__- s>040@0@0B- -z0023 VZ):;<. s&)A"JJ)Asz*got an unexpected keyword argument {arg!r})rrrrr"rrrrrrrrr+ StopIterationrrr(rr2rJrarK_bound_arguments_cls)r@rrrrr parameters_exarg_valspos_only_param_in_kwargsarg_valrrrr kwargs_paramrs r_bindzSignature._bind9 sy $//0023  :#% G 4x.Z4 ,EzzlM%BB(;=BFGzz_4#* h/05f %**-zzV+ >N0N'BII$)JJJ016:;-4Iejj)U\ __]J?Ezz\)$ zz_,J 0 **Z0)0 *%5@8 '/5 ,++,)117 II&)A&282 @GG f.H011((y99W%O#$CD$NO]!) ;'; ,E zz_4v- ::)995;;EB$). ** 405 V0K*/ #-2HM!$zz]:*9*,"QC"%**W*"MC"+C.d:K% ) ;r F  EJJ/$A49MMV4K#$J$*FzF$:'>?A Arc|d|_yrrrs rrzSignature.__setstate__ s"'(<"=rcNdj|jj|S)Nz<{} {}>rrs rrxzSignature.__repr__ s 7 7>>rcg}d}d}|jjD]u}t|}|j}|tk(rd}n|r|j dd}|t k(rd}n|tk(r|r|j dd}|j |w|r|j ddjdj|}|jtur)t|j}|dj|z }|S)NFT/r!z({})r-z -> {}) rrrr"rrrrr+rKrr(r+) r@rrender_pos_only_separatorrender_kw_only_separatorrrr"renderedannos rrqzSignature.__str__ s$)!#' __++-EE I::D'',0)* c",1)&,1(&+C c",1( MM) $5.8 % MM# ==6!23  ! ! /#D$:$:;D - -Hrr)rryr7r<r;r#r.r rr(rrrr]r rrrrrrrrrrr}rrxrqr}rrr$r$ s,6IN) E24V)-24h%)4u[[  ''%*U ?:= 9.3I:V(6A >?+rr$rc6tj|||||S)z/Get a signature object for the passed callable.r)r$r])rrrrrsrts rrere s'  " "3~+26H # VVrceZdZdZdZdZdZdezZdezZdezZ dezZ d ezZ eezZ eZ eezZeZeezezZeezZe ezezZe ezZd Zd Zy ) r rjrF @iN)rryr7SIMPLEWRITABLEFORMATNDSTRIDES C_CONTIGUOUS F_CONTIGUOUSANY_CONTIGUOUSINDIRECTCONTIG CONTIG_ROSTRIDED STRIDED_RORECORDS RECORDS_ROFULLFULL_ROREADWRITEr}rrr r  s FH F BRiG'>L'>LG^NwH (]FI GJ 6)G6!J h  'DG D Err c ddl}ddl}|j}|jdd|jdddd |j }|j }|j d \}}} |j|x}} |r&|j!d}  }| D]} t#|| } jtj$vr0tdtj tjd|j&rtdj|tdjt)| tdj| j*| ur^tdjt-| j.t1| drNtdj| j2n) t5|\}}tdj|tdytt7y#t$ra} d j|t| j| } t| tj tjdYd} ~ d} ~ wwxYw#t$rYwxYw)z6 Logic for inspecting an object given at command line rjNrzCThe 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:zFailed to import {} ({}: {}))rrr5z#Can't get info for builtin modules.rFz Target: {}z Origin: {}z Cached: {}z Loader: {}__path__zSubmodule search path: {}zLine: {}rE)argparser^ArgumentParser add_argument parse_argsr partition import_modulerr+rrprintrstderrexitr8rbuiltin_module_namesdetailsrK __cached__rrnrrr*rJ)rr^parserrtargetmod_name has_attrsattrsrrrrpartspart__rs r_mainr' s*  $ $ &F 9:  k, HJ    D [[F!'!1!1#!6Hi.y..x88f C D#t$C#222 3#**E   || l!!&)* l!!-"789 l!!&"3"345 &= ,%%d6+<+<&=> ?vz*188IJ 1'_ Fj''/0 d  inG ,33H48I4F4F479 c #  8  s+3H J I>AI99I> J  J rTr)F)rF)r})T)TNNF)r< __author____all__rrrcollections.abcrenumimportlib.machineryr^rrwr[rrrrrrrkeywordrkoperatorrlrmrnweakrefrorrrmod_dictCOMPILER_FLAG_NAMESrrrr%r.rarSr^r_rWrr]r\rYrr[rrrrdrVrPrOrZrUrQrcrXrTrRr`rbrNrrDrErr'rHrhrMr9rBr<r(r=rGrKr/rrrFrr NodeVisitorrr*r9rr r5rLrJrir7rr0rr?rr1r+r,rr-r;rGr6rr8rkr&rr~r>rC_fieldsrrrIrBr)rfrgrrrvrrrrr lru_cacherrr4r r!r"rrAr@r rrr r;r:rrrrr3r2WrapperDescriptorTyperrrrrrrrrrrArDrTrrrr(IntEnumrjr4rr5rr7rr8rr:rr#r r$reIntFlagr rrr}rrr$s7@9 i X    /' 9  # # ) ) +DAqHUQY ,q(%)vt0$0A( ? 5()> 5()> 2 ,-XJ I383"3;3 /.297(0(T3 : {$E F ph @0 <|& :,8 28 ,^ ) 3??>B0H+%Z"!44l$&0*+6 {$: ; 86MO Z ?9 ""9 8 ? (.7 D*:x(LM 14j &S T  - -7O)AV  j93D3D&D E  @ @  C5' H y)11 MM*5==4$ '0/h    $&  ! $   ! $."77!33!;;!557 $I?X*4 *G2/+dK8\ < 8