\dVdZdZgdZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZmZeZejD] \ZZ eede z<[[ [d Z!ddd d d Z"d Z#dZ$dZ%dZ&dZ'e(edrdZ)ndZ)e(edrdZ*ndZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2d Z3d!Z4d"Z5d#Z6d$Z7d%Z8d&Z9d'Z:d(Z;dd)Zd-Z?d.Z@dd/d0ZAd1ZBd2ZCd3ZDd4ZEd5ZFd6ZGd7ZHd8ZIdd9ZJiZKiZLdd:ZMGd;dejPZQd?ZRd@ZSGdAdBeNZTGdCdDZUdEZVdFZWdGZXdHZYddIZZedJdKZ[dLZ\edMdNZ]dOZ^edPdQZ_dRZ`ddSZadTZbecdUdVdWfdXZddYZedZZfd[Zged\d]Zhd^Zied_d`ZjGdadbejZkdcZlddZmddfZndgZoedhdiekjpzZqGdjdkeqZrddlZsddmZtdnZuddoZvddpZwexZydqZzdrZ{dsZ|dtZ}duZ~eyfdvZdwZdxZdyZdzZd{Zd|Zd}Zd~ZdZdZdZdZejejejejfZdZddZdZdZdZdZddZddZ ddZddddd ddZGddZGddZGddejZejZejZejZejZejZGddZGddZGddZdddd ddZdZedkr edSdS)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 )`ArgInfo Arguments Attribute BlockFinderBoundArguments 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 getargvaluesgetattr_staticgetblock getcallargs getclasstreegetclosurevars getcommentsgetcoroutinelocalsgetcoroutinestategetdocgetfile getframeinfogetfullargspecgetgeneratorlocalsgetgeneratorstategetinnerframes getlineno getmembersgetmembers_static getmodule getmodulenamegetmrogetouterframes getsource getsourcefilegetsourcelines indentsize isabstract isasyncgenisasyncgenfunction isawaitable isbuiltinisclassiscode iscoroutineiscoroutinefunctionisdatadescriptorisframe isfunction isgeneratorisgeneratorfunctionisgetsetdescriptorismemberdescriptorismethodismethoddescriptorismethodwrapperismodule isroutine istraceback signaturestacktraceunwrapwalktreeN) iskeyword) attrgetter) namedtuple OrderedDictCO_iFglobalslocalseval_strc>t|trt|dd}|rCt|dr3|dd}t|t jrd}nd}d}t|dd}|r3tj|d}|rt|dd}tt|} |} nt|t j r&t|dd}t|d}d} d} nHt|r't|dd}t|dd}d} |} nt|d|iSt|tst|d|siS|st|S| S t| d r| j} t| t jr| j} ; t| dr| j}|| fd |D} | S) 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 NoneT __wrapped__chi|].\}}|t|ts|nt|/S) isinstancestreval).0keyvaluerirjs ..\python\lib\inspect.py z#get_annotations..sO((( Cs++MeWf1M1M((()rutypegetattrhasattrrntypesGetSetDescriptorTypesysmodulesdictvars ModuleTypecallable TypeError ValueErrorrr functoolspartialfuncrqitems) objrirjrkobj_dictann obj_globals module_namemodule obj_localsr` return_values `` r{r)r)sZ#t!I3 D11  %00 ,,0$77C#u9:: C c<66  @[__[$77F @%fj$?? $s))__  C) * *Ic,d33c:..   # Ic,d33c=$77  3GGGHHH { c4 PCNNNOOO  Cyy  v}-- +&)"344   6= ) ) - ,K ~((((())++(((L r}c6t|tjS)zReturn 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))rurrobjects r{rZrZs fe. / //r}c,t|tS)zReturn 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)rur~rs r{rLrL$s fd # ##r}c6t|tjS)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)rur MethodTypers r{rWrW,s fe. / //r}ct|st|st|rdSt|}t |dot |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__rLrWrRr~rrtps r{rXrX6sbv(6**j.@.@u fB 2y ! ! @'"i*@*@&@@r}ct|st|st|rdSt|}t |dpt |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 r{rPrPJs_v(6**j.@.@u fB 2y ! ! >WR%>%>>r}MemberDescriptorTypec6t|tjS)Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.)rurrrs r{rVrVZ &%"<===r}cdS)rFrtrs r{rVrVb ur}rc6t|tjS)Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.)rurrrs r{rUrUkrr}cdS)rFrtrs r{rUrUsrr}c6t|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)rur FunctionTypers r{rRrRzs fe0 1 11r}ct|r|j}t|tj|}t |st |sdSt |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) rW__func__r_unwrap_partialrR_signature_is_functionlikebool__code__co_flags)fflags r{_has_code_flagrst 1++ J 1++!!$$A qMM7::u  #d* + ++r}c,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.)rr rs r{rTrT #| , ,,r}c,t|tS)zuReturn true if the object is a coroutine function. Coroutine functions are defined with "async def" syntax. )rr rs r{rOrOrr}c,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. )rr rs r{rIrIs #1 2 22r}c6t|tjS)z7Return true if the object is an asynchronous generator.)rurAsyncGeneratorTypers r{rHrHs fe6 7 77r}c6t|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)rur GeneratorTypers r{rSrSs fe1 2 22r}c6t|tjS)z)Return true if the object is a coroutine.)rur CoroutineTypers r{rNrNs fe1 2 22r}ct|tjpYt|tjo t |jjtzpt|tj j S)z?Return true if object can be passed to an ``await`` expression.) rurrrrgi_coderr collectionsabc Awaitablers r{rJrJsa vu2 3 3 : vu2 3 3 FV^,/DDEE : v{8 9 9;r}c6t|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))rur TracebackTypers r{r\r\s fe1 2 22r}c6t|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)rur FrameTypers r{rQrQs feo . ..r}c6t|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)rurCodeTypers r{rMrMs. fen - --r}c6t|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)rurBuiltinFunctionTypers r{rKrKs fe7 8 88r}c6t|tjS)z.Return true if the object is a method wrapper.)rurMethodWrapperTypers r{rYrYs fe5 6 66r}ct|p;t|p,t|pt|pt |S)zz_getmembers..Ms $q'r}ry)setdirrLrArrmrrurDynamicClassAttributeappendAttributeErroraddsort) r predicategetterresults processednamesmrorkvryrzs r{ _getmembersr&sGI KKEv i&..( ( ( ( M//11((DAq!!U%@AA( Q( (    D  F63''Ei$$      $-'' M#.EE(  E   )IIe,, ) NNC< ( ( ( c LL))L*** Ns%AB B)(B)3C  'C76C7c.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 r{r=r=Ps vy' 2 22r}c.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. )rr-rs r{r>r>Us vy. 9 99r}rzname kind defining_class objectc t|}tt|}td|D}|f|z}||z}t|}|D]W}|jD];\}}t |tjr|j | |z'classify_class_attrs..s0HHCc$.G.GC.G.G.G.GHHr}Nrmz)__dict__ is special, don't want the proxy __objclass__z static methodz class methodpropertymethoddata)rAr~tuplerrmrrurrfgetrr Exceptionr __getattr__r staticmethodBuiltinMethodType classmethodClassMethodDescriptorTyperr[rr)rrmetamro class_bases all_basesrrrrresultrrhomeclsget_objdict_objlast_clssrch_clssrch_objexcrkinds r{r"r"es76 ++CT#YYGHH7HHHHHG&3,Kg%I HHE  M''))  DAq!U899 af>P Q FIDD y  +:%%#$OPPP!#t,,"'>7CC+--#G#H$/00#*8T4#@#@#w..'/H$+00%'/';';C'F'FHH-%%%$H%#w..'/H+"*/    0  Dt}$$=.'))"G % ?  ,gg( hu/F G H H "DCC ;0O"P Q Q !DCC ( + + DCC s^^ DDD idGS99::: d Ms$%E+8E EE+ E?:E?c|jS)zHReturn tuple of base classes (including cls) in method resolution order.)__mro__)rs r{rArAs ;r}stopc>d}nfd}|}t||i}tj}||r_|j}t|}||vst ||kr"t d||||<||_|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. Nc"t|dSNrrrrs r{ _is_wrapperzunwrap.._is_wrappers1m,, ,r}c<t|do | Srr)rrs r{rzunwrap.._is_wrappers"1m,,|j}|j}t|r|jdz|z|jkr|}n|j }nt|t r4|j}|j}t|}|t|||urdSnt%|st'|rd|j}|j}t|||urdSt+|r2t|dd}t|t,r ||vr||SndS|jD]/} t||j}n#t$rY%wxYw||cS0dS)Nrr+ __slots__)rLrr__doc__rrWr__name____self__r __class__rRr/rKr-rurrrXrPrrVr)rrdocrselfrrslotss r{_finddocr9ss|| K  D6!!,CC%H?JJJt}}(|$| DMM ! GD$--z : :cl J JCC.CC C|oo ;'#t,,C7748 3|| DMM !   #d *c.> > >CC.CC C " "x} ;'#t,,C7748 C $4S$9$9 | 3  S ( (4 c " " #Cd33E%&& #45==T{"t  $%%-CC    H  ?JJJ  4s+ 88 H H,+H,c |j}n#t$rYdSwxYw|) t|}n#ttf$rYdSwxYwt |t sdSt |S)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)r2rr9rrurvr#)rr6s r{r5r5Ps n tt { 6""CC *   44  c3  t C==s .AAc |d}tj}|ddD]G}t |}|r"t ||z }t ||}H|r|d|d<|tjkr3tdt |D]}|||d||<|r&|ds||r|d|r'|ds|d|r|dd |S#t$rYdSwxYw)zClean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed. Nrbr,) r&r.rmaxsizer r'minrangepopjoin UnicodeError)r6linesmarginr(contentindentis r{r#r#cs    &&t,, !""I - -D$++--((G -TW,VV,,  )Qx((E!H CK  1c%jj)) G GeAhvww6G588 E"I  IIKKK E"I  E!H  IIaLLL E!H yy) tts'E EEct|r:t|ddr|jStd|t |rt |drVtj |j }t|ddr|jS|j dkrtdtd|t|r|j }t|r|j}t!|r|j}t%|r|j}t)|r|jStdt-|j) z@Work out which source or compiled file an object was defined in.__file__Nz{!r} is a built-in modulerp__main__source code not availablez{!r} is a built-in classzVmodule, class, method, function, traceback, frame, or code object was expected, got {})rZrrJrr!rLrrrrnrpOSErrorrWrrRrr\tb_framerQf_coderM co_filenamer~r3)rrs r{r6r6s|D 6:t , , #? "3::6BBCCCvC 6< ( ( ;[__V%677Fvz400 '& J..9:::299&AABBB!&!6!v f~~"!! 77=vLL)8+8+ , ,,r}ctj|}dtjD}||D]&\}}||r |d|cS'dS)z1Return the module name for a given file, or None.c2g|]}t| |fSrt)r )rxsuffixs r{ z!getmodulename..s;FFFf++v&FFFr}N)ospathbasename importlib machinery all_suffixesrendswith)rVfnamesuffixesneglenrSs r{r@r@s G  T " "EFF"+"5"B"B"D"DFFFH MMOOO""" >>& ! ! "&> ! ! ! " 4r}ct|tjjdd}|tjjddz }t fd|Dr>t jdtjj dzn,t fdtjj DrdSt j rSt|}t|ddStt|ddddStjvrSdS)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. Nc3BK|]}|VdSrr[rxsfilenames r{rz getsourcefile..s1 ? ?A8  Q   ? ? ? ? ? ?r}rbc3BK|]}|VdSrrarbs r{rz getsourcefile..sA 9 9aX  q ! ! 9 9 9 9 9 9r} __loader____spec__loader)r6rXrYDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESanyrUrVsplitextSOURCE_SUFFIXESEXTENSION_SUFFIXESexistsr?r linecachecache)rall_bytecode_suffixesrrds @r{rDrDsUvH%/GJY0LQQQOO ? ? ? ?)> ? ? ???G$$X..q1'7:;  9 9 9 9$7 9 9 9 9 9t w~~h vx ( (Fv|T**6 T22Hd C C O Y_ $ $ % $r}c|t|pt|}tjtj|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.)rDr6rUrVnormcaseabspath)r _filenames r{r*r*sF !&)))r^rr generic_visitrA)r7nodes r{visit_FunctionDefz_ClassFinder.visit_FunctionDefsn $)$$$ *%%% 4     r}cP|j|j|jd|jkr5|jr|jdj}n|j}|dz}t||||j dS)Nr+rbr=) r^rrrrBdecorator_listlinenorrrA)r7r line_numbers r{visit_ClassDefz_ClassFinder.visit_ClassDefs $)$$$ =CHHTZ00 0 0" *"1!4; "k  1 K%k22 2 4    r}N)r3rpr-rrvisit_AsyncFunctionDefrrtr}r{rrsI!!!/     r}rct|}|rtj|nHt|}|dr|dst dt||}|rtj||j }ntj|}|st dt|r|dfSt|r|j }d |}tj|}t!|} ||t d#t$$r}|jd} || fcYd}~Sd}~wwxYwt)|r|j}t-|r|j}t1|r|j}t5|r|j}t9|rt;|d st d |jd z } t?j d } | dkrH || } n#tB$rt d wxYw| "| rn | d z } | dkH|| fSt d)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.<>rLzcould not get source coderbzcould not find class definitionNco_firstlinenoz"could not find function definitionr=z>^(\s*def\s)|(\s*async\s+def\s)|(.*(??? ?$q(jZ[[Qhh 9T{ 9 9 97888 9yy !8DQhhd{ . / //s*#E E,E'!E,'E,H##H=c t|\}}n#ttf$rYdSwxYwt|rAd}|r|ddddkrd}|t |krP||dvr4|dz}|t |kr||dv4|t |kr||dddkrg}|}|t |krm||dddkrY||||dz}|t |kr||dddkYd|SdSdS|dkrt||}|dz }|dkr|| dddkrt|||kr|| g}|dkr|dz }|| }|dddkrt|||krg|g|dd<|dz }|dkrnS|| }|dddkrt|||kg|rE|ddkr'g|dd<|r|ddk'|rE|d dkr'g|d d<|r|d dk'd|SdSdSdSdS) zwGet lines of comments immediately preceding an object's source code. Returns None when source can't be found. Nrbz#!r=)r#rrr,) r%rMrrZr striprr&rBrFr')rrDrstartcommentsendrGcomments r{r2r2cs  (( tt Y tt!% 4U1Xbqb\T))15c%jj  U5\%7%7%9%9Y%F%FAIEc%jj  U5\%7%7%9%9Y%F%F 3u::  %,rr"2c"9"9HCE ""uSz"1"~'<'<c 5 5 7 7888AgE ""uSz"1"~'<'<778$$ $  "9"9 E$K((Qh !88c ))++BQB/366 uSz " "f , ,c --//66889HQwwAg*//1188::bqbkS((Zc -C-Cv-M-M$+9HRaRL'CQww#Cj3355<<>>G bqbkS((Zc -C-Cv-M-M  "x{0022c99!!  "x{0022c99 #x|1133s:: "  #x|1133s::778$$ $%  866 , ,s **ceZdZdS)rNrrtr}r{rrsr}rceZdZdZdZdZdS)rz@Provide a tokeneater() method to detect the end of a code block.chd|_d|_d|_d|_d|_d|_d|_dS)NrbFr=)rGislambdastartedpassline indecoratorlast body_col0r7s r{rzBlockFinder.__init__s8      r}c|js6|js/|dkrd|_n|dvr|dkrd|_d|_d|_dS|tjkr4d|_|d|_|jrt|jr d|_dSdS|jrdS|tjkr3|j |jr |d|_ |j dz|_ d|_dS|tj kr#|j dz |_ |j dkrtdS|tj kr+|j |d|j kr|d|_dSdSdS|j dkr!|tj tj fvr tdSdS)N@T)defclasslambdarFrbr=)rrrrtokenizeNEWLINErrINDENTrrGDEDENTCOMMENTNL)r7r~tokensrowcolerowcolr(s r{ tokeneaterzBlockFinder.tokeneaters|( D$4( ||#'  444H$$$(DM#  DMMM X% % %!DM DI} !   )#(    ) ) ]  D X_ $ $~%$,%!(+/DK DMMM X_ $ $+/DK{a    X% % %~)gajDN.J.J#AJ *).J.J[A  $x/?.M"M"M  "M"Mr}N)r3rpr-r2rrrtr}r{rrs8JJ)))))r}rct} tjt|j}|D] }|j| n#t tf$rYnwxYw|d|jS)z@Extract the block of code at the top of the given list of lines.N) rrgenerate_tokensiter__next__rrIndentationErrorr)rD blockfindertokens_tokens r{r.r.s--K )$u++*>?? , ,F "K "F + + + , ( )     "+"" ##s5AAAc t|}t|\}}t|r|j}t |st |r|jjdkr|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.zrbNr=) r`r%r\rNrZrQrOco_namer.rrDrs r{rErEsF^^FV$$KE46! 0 0#]2j@@axdee %%tax//r}cPt|\}}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)rErBrs r{rCrCs% !((KE4 775>>r}cg}|tdd|D]L}|||jf||vr*|t ||||M|S)z-Recursive helper function for getclasstree().rpr3r)rrdrrra)classeschildrenparentrcs r{raras~G LLZ j99L::: ??1;'((( == NN8HQK1== > > > Nr}c4i}g}|D]c}|jrA|jD]8}||vrg||<|||vr||||r||vrn9J||vr||d|D]}||vr||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)rrra)runiquerrootsrrs r{r0r0sH E    ; + 7 7))')HV$HV,,,V$++A...6f// e^^ LLOOO!!  LL E8T * **r}rzargs, varargs, varkwct|s"td||j}|j}|j}t |d|}t ||||z}d}||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 objectNrbr=) rMrr! co_varnames co_argcountco_kwonlyargcountlistrrrr) cornargsnkwargsr kwonlyargsstepvarargsvarkws r{r+r+s "::@3::2>>??? NE NE"G fuf  DeE%-/011J D WEG {Z.'  E {^#&u% TJ& 7 77r}rzGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc   t|ddtd}n"#t$r}td|d}~wwxYwg}d}d}g}g}i}d} i} |j|jur |j|d<|jD]} | j} | j } | tur/| | | j | jur | | j fz } n| tur/| | | j | jur | | j fz } nN| tur| }nB| tur.| | | j | jur | j | | <n | t ur| }| j| jur | j|| <| sd} | sd} t%||z||| || |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_chainsskip_bound_argsigclsrkzunsupported callableNrtreturn)_signature_from_callablerrrreturn_annotationempty parametersvaluesrr_POSITIONAL_ONLYrdefault_POSITIONAL_OR_KEYWORD_VAR_POSITIONAL _KEYWORD_ONLY _VAR_KEYWORD annotationr)rsigexrrr posonlyargsr annotationsdefaults kwdefaultsparamrrs r{r8r88s  8"'t=B6;.705 777 888 .//R7 8 DG EKJKHJ CI-- # 5 H&&((11zz # # #   t $ $ $}EK//U],, + + + KK   }EK//U],, _ $ $GG ] " "   d # # #}EK//#(= 4 \ ! !E  5; . . % 0K    {T)7E8!:{ < <.repls#;;==D$$Y// /r}z[\w\.]+rxr+) rrsubreprrur GenericAliasrvr~rpr-)r base_moduler s r{r&r&sz<..(:: 0 0 0vj$Z(8(8999*e011:*d##A  Z$= = =* *$S()@@@   r}c4t|ddfd}|S)Nrpc$t|Sr)r&)rrs r{_formatannotationz5formatannotationrelativeto.._formatannotations F333r})r)rrrs @r{r'r's3 V\4 0 0F44444 r}c d|zS)N*rtrs r{rrs sTzr}c d|zS)N**rtrs r{rrs TD[r}c&dt|zS)N=r)rzs r{rrscDKK.?r}c|||fd}g} tt|D]&} | ||| '|r0| |||||z|r0| |||||zdd| 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<|||||zSrrt)rrj formatarg formatvalues r{convertz formatargvalues..converts#yVD\!:!:::r}(, ))r@r rrB) rrrrjr formatvarargs formatvarkwr r!specsrHs r{r(r(s$#;;;; E 3t99  '' WWT!W%%&&&&L ]]7++kk&/.J.JJKKK F [[''++fUm*D*DDEEE 5!! !C ''r}c"fd|D}t|}|dkr |d}n@|dkr dj|}n/dj|dd}|dd=d||z}td |||rd nd |dkrd nd |fz)Nc6g|]}|vt|Srtr)rxrrs r{rTz&_missing_arguments..s) C C CDF0B0BT$ZZ0B0B0Br}r=rbrz {} and {}z , {} and {}r#z*%s() missing %i required %s argument%s: %s positional keyword-onlyrrc)r r!rBr)f_nameargnamesposrrmissingrctails ` r{_missing_argumentsr2s C C C CH C C CE%jjG!|| !H A K  &#}#U233Z0 "##J IIe  t # @W&)=ll~#qLLbbc166 7 77r}c t||z }tfd|D}|r |dk} d|fz} nH|rd} d|t|fz} n/t|dk} tt|} d} |rd} | |dkrdnd||dkrdndfz} td || | rdnd|| |dkr|sd nd fz) Ncg|]}|v| Srtrt)rxargrs r{rTz_too_many..s???r}r=z at least %dTz from %d to %drz7 positional argument%s (and %d keyword-only argument%s)rcz5%s() takes %s positional argument%s but %d%s %s givenwaswere)r rvr) r-rkwonlyrdefcountgivenratleast kwonly_givenpluralr kwonly_sigmsgs ` r{ _too_manyr@s&$ii("G????v???@@LAwj( #d)) 44Ta#d))nnJ@GEQJJSSB $0A$5$5SS2?? K S/##R qjjjUU6 CC D DDr}c t|}|\}}}}}} } |j} i} t|r|j |jf|z}t |} t |}|rt |nd}t | |}t |D]}||| ||<|rt||d| |<t||z}|ri| |<| D]H\}}||vr"|st| d||| ||<+|| vrt| d||| |<I| |kr|st| ||||| | | |krW|d||z }|D]}|| vrt| |d| t|||z dD]\}}|| vr ||| |<d}|D]}|| vr| 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'.Nrbz&() got an unexpected keyword argument z$() got multiple values for argument Tr=F)r8r3rWr4r r?r@rrrrr@r2 enumerate)rr+namedspecrrrrrkwonlydefaultsrr- arg2valuenum_posnum_args num_defaultsnrHpossible_kwargskwrzreqr5r0kwargs r{r/r/s $  DFJCD'5(J ]FI~~3$-3m% 2 *ooG4yyH$,33x===!L GXA 1XX++'] $q'3":abb>22 '$+,,O  %[[]]   E _ $ $ .!'!-...#(Ie R  ??#VVRR)** * " '&$ G\I ' ' '+H|++, A AC)##"63i@@@X %<%=%= >?? - -FAs)##!)! #G  ! ! %>"9"9#1%#8 %  1 A6:ui@@@ r}rz"nonlocals globals builtins unboundcvt|r|j}t|s"td||j}|ji}n$dt|j|jD}|j }| dtj }t|r|j }i}i}t}|jD]U}|dvr ||||<#t $r5 ||||<n%#t $r||YnwxYwYRwxYwt%||||S)a Get the mapping of free variables to their current values. Returns a named tuple of dicts mapping the current nonlocal, global and builtin references as seen by the body of the function. A final set of unbound names that could not be resolved is also provided. {!r} is not a Python functionNc$i|] \}}||jSrt) cell_contents)rxvarcells r{r|z"getclosurevars..Es1   T $$   r} __builtins__)NoneTrueFalse)rWrrRrr!r __closure__zip co_freevarsrqrnrxrmrZrco_namesKeyErrorrr) rcode nonlocal_vars global_ns builtin_ns global_vars builtin_vars unbound_namesrs r{r1r10s~~} d  F7>>tDDEEE =D     !143CDD    I~x/@AAJ )( KLEEM ( ( , , ,  ( )$K   ( ( ( (%/%5 T"" ( ( (!!$''''' ( ( }k#] 4 44s6 C'' D&2 C>=D&>D D&D  D&%D& _Tracebackz+filename lineno function code_context indexc*eZdZddfd ZdZxZS)r!N positionscbt||||||}||_|Srsuper__new__rh) rrdrfunction code_contextindexrhinstancer5s r{rlzTraceback.__new__hs077??3&(LRWXX&r}crd|j|j|j|j|j|jS)NzcTraceback(filename={!r}, lineno={!r}, function={!r}, code_context={!r}, index={!r}, positions={!r}))r!rdrrmrnrorhrs r{__repr__zTraceback.__repr__ms9@@F t{DM4;L DNA,A, -r}r3rpr-rlrr __classcell__r5s@r{r!r!gsTSW -------r}r!cH|jj|j}}t||Sr)rNrOtb_lasti_get_code_position)tbr^instruction_indexs r{_get_code_position_from_tbr{ss$ k0"+ D d$5 6 66r}c|dkrdS|}ttj||dzdS)Nrb)NNNNr) co_positionsnext itertoolsislice)r^rz positions_gens r{rxrxwsG1''%%''M   0AQ0FMM N NNr}r=c t|rt|}|j}|j}n!|j}t |j|j}|d||g|ddR^}}n|g|R^}}|d}t|s"td |t|pt|}|dkrv|dz |dzz } t|\}}tdt|t!||z }||||z}|dz |z }n#t"$rdx}}YnwxYwdx}}t%|||jj||t)j|S)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.rbNr=z'{!r} is not a frame or traceback objectrrg)r\r{ tb_linenorNf_linenorxrOf_lastirQrr!rDr6r%maxr?r rMr!rdis Positions) rcontextrhrrdrrDrros r{r7r7~s5D.u55 &u|U]CC |"F;Yqrr];; "/Y// q\F 5>>QAHHOOPPPU##5wu~~H{{ WaZ' '$U++KE43uc%jj7&:;;<r} _FrameInforc*eZdZddfd ZdZxZS)rNrgc dt|||||||}||_|Srrj) rrrdrrmrnrorhrpr5s r{rlzFrameInfo.__new__s277??3x@@F DM4; !4:t~A?A? @r}rsrus@r{rrs[Z^ @@@@@@@r}rcg}|rCt||}|f|z}|t|d|ji|j}|C|S)zGet 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.rh)r7rrrhf_back)rr framelisttraceback_info frameinfos r{rBrBsi I %eW55H~- IR9QRRSSS   r}cg}|rHt||}|jf|z}|t|d|ji|j}|H|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.rh)r7rNrrrhtb_next)ryrrrrs r{r;r;sk I %b'22[N^3 IR9QRRSSS Z  r}cXttdrtjdndS)z?Return the frame of the caller or None if this is not possible. _getframer=N)rrrrtr}r{r$r$s&&sK88 B3=   dBr}cFttjd|S)z@Return a list of records for the stack above the caller's frame.r=)rBrrrs r{r^r^s #-**G 4 44r}cPttjd|S)zCReturn a list of records for the stack below the current exception.r)r;rexc_infors r{r_r_s #,..+W 5 55r}cLtjd|S)Nr)r~rmr)klasss r{_static_getmrors = # + +E 2 22r}ci} t|d}n#t$rYnwxYwt||t SNrm)r__getattribute__rrrn _sentinel)rattr instance_dicts r{_check_instancersYM //Z@@      88M4 3 33s  --ct|D]E}tt|tur |j|cS#t $rYAwxYwFtSr)r_shadowed_dictr~rrmr])rrentrys r{ _check_classrsw&& $u++ & &) 3 3 ~d++++     4 s A AAcJ t|n#t$rYdSwxYwdSNFT)rrrs r{_is_typers?s uu 4s   ctjd}t|D]a} ||d}t|tjur|jdkr |j|us|cSR#t$rY^wxYwtSr) r~rmrrrrr3rr]r)r dict_attrr class_dicts r{rrs j)I&& " " ""**511*=J$$(BBB':55+u44!!!!5     D  sA44 BBc$t}t|sSt|}t|}|tust|tjurt ||}n|}t||}|turw|turntt|dturJtt|dtus$tt|dtur|S|tur|S|tur|S||urbtt|D]E}tt|tur |j |cS#t$rYAwxYwF|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) rrr~rrrrrrrmr]r)rrrinstance_resultrr klass_resultrs r{r-r-s O C==S "5))  " " OOu9 9 9-c488Ot,,Li''L ,I,I \**I 6 6i G G l++Y 7 7y H HD.. ==YNN i''9$$ e||#DKK00  Ed5kk**i77 >$////D8 i   s E'' E43E4rrrrcd|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_suspendedrgi_framerr) generators r{r:r:Gs;! r}ct|s"td|t|dd}| |jjSiS)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)rSrr!rrr)rrs r{r9r9YsZ y ! !L8?? JJKKK Iz4 0 0E !** r}rr r rcd|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_suspendedr cr_framerr) coroutines r{r4r4qs;! r}c: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 r{r3r3s( Iz4 0 0E ~ r}cx t||}t|ts|SdS#t$rYdSwxYw)zPrivate helper. Checks if ``cls`` has an attribute named ``method_name`` and returns it only if it is a pure python function. N)rru_NonUserDefinedCallablesr)r method_namemeths r{"_signature_get_user_defined_methodrs` sK(($ 899 K   s + 99rtcd|j}t|}|jpd}|jpi}|r||z} |j|i|}n7#t $r*}d|} t| |d}~wwxYwd} |D]j\} } |j | } | j tur| | 8| j tur;| |vrd} | | || <n| | j| j t ur| | || <n#t"$rYnwxYw| r| j tusJ| j tur=|| t }||| <|| | j t t&fvr|| B| j t(ur| | jl||S) zPrivate helper to calculate how 'wrapped_sig' signature will look like after applying a 'functools.partial' object (or alike) on it. rtz+partial object {!r} has incorrect argumentsNFT)rrr)rrfrrkeywords bind_partialrr!r argumentsrrrArreplacerrr] move_to_endrrr) wrapped_sigr extra_args old_params new_params partial_argspartial_keywordsbarr?transform_to_kwonly param_namer arg_value new_params r{_signature_get_partialrs 'JZ--//00J<%2L'-21!L0 & %[ %| H7G H H &&&;BB7KKoo2%&  '--//0+0+ E# J Z0Iz---z***z333!111+/'-2]]9]-M-MJz**NN5:...z]**).y)I)I :&C    D F  +:%55555z333&z2:: :NN )2 :&&&z2222 |<<<&&z2222..uz***   **;*;*=*=  > >>s* A B%BB% E EEcRt|j}|r|djtt fvrt d|dj}|ttfvr |dd}n|turt d| |S)zWPrivate helper to transform signatures for unbound functions to bound methods. rbzinvalid method signaturer=Nzinvalid argument typer) rrrrrrrrrrr)rparamsrs r{_signature_bound_methodrs 3>((** + +F 5VAY^ m'DDD3444 !9>D &(8999  & &455 5 ;;&; ) ))r}ct|p3t|p$t|tp|tt fvS)zxPrivate helper to test if `obj` is a callable that might support Argument Clinic's __text_signature__ protocol. )rKrXrurr~rrs r{_signature_is_builtinrsH cNN " s # # " s4 5 5 " D&> ! #r}ct|rt|rdSt|dd}t|dd}t|dt}t|dt}t|dd}t |t jo_t |toJ|dupt |to1|dupt |tot |tp|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. Fr3Nr __defaults____kwdefaults__ro) rrLr_voidrurrrvrr)rrr^rrrs r{rrs C==GCLLu 3 D ) )D 3 D ) )DsNE22H.66J#0$77K tU^ , , E tS ! ! E   <He!.Is) C C C1 CQXXg   C C Cr}r<Frb,Tr=/$r$r# r) r.rrrrrOP ERRORTOKENr~r~ENCODINGstringrB)r]self_parameterlast_positional_onlyrDr token_stream delayed_commaskip_next_commar rcurrent_parameterrrtr~rclean_signatures r{"_signature_strip_non_python_syntaxr6s %$$$N C C (=(= C C CEU $I$Y//LMO D +C B!J \A 6X& & & & & vqxf 2::}}"+&+OO,,,,$(M%*%}}****+333"&'81'<$ J  Vs]]!))).N   !MRZZfmmD  F cMM CHHHggdmmO N,@ @@r}Tc|jt|\}}}d|zdz} tj|}n#t$rd}YnwxYwt |tjs"td|j d} gj d}itdd} | r)tj | d}|r|jtj dfdGfd d tjffd } t%| jj} t%| jj} t+j| | d }|jnjt3t%t5|D]!\}\}}| ||||krj"| jjrj| | jjjt=| jj| jj D]\}}| ||| jj!rj"| | jj!|jsJtd d}|du}tG|}|r|s|r$dn&d%j} | d<||j S)zdPrivate helper to parse content of '__text_signature__' and return a Signature based on it. zdef fooz: passN"{!r} builtin has invalid signaturerbrpctt|tjsJ|jt d|jS)Nz'Annotations are not currently supported)rurr5rr)rs r{ parse_namez&_signature_fromstr..parse_names8$((((( ? &FGG Gxr}c D t|}n7#t$r* t|}n#t$rtwxYwYnwxYwt|tt t tttdfrtj |Str) rw NameErrorrrurvintfloatbytesrr~rConstant)rcrz module_dictsys_module_dicts r{ wrap_valuez&_signature_fromstr..wrap_values !K((EE ! ! ! !Q00 ! ! !   ! ! ec3udDJJG H H '<&& &s# A0AAAAc*eZdZfdZfdZdZdS),_signature_fromstr..RewriteSymbolicscg}|}t|tjr;||j|j}t|tj;t|tjst||jd t|}|S)Nr+) rurrrrrzNamerrrBreversed)r7rarJrzrs r{visit_Attributez<_signature_fromstr..RewriteSymbolics.visit_AttributesAAQ ..    GQ .. a** !  HHQTNNNHHXa[[))E:e$$ $r}c~t|jtjst |jSr)ructxrLoadrr)r7rrs r{ visit_Namez7_signature_fromstr..RewriteSymbolics.visit_Names5dh11 # ll":dg&& &r}cn||j}||j}t|tjrt|tjst t|jtjr!t j|j |j zSt|jtj r!t j|j |j z St|jtj r!t j|j |j zSt r) rleftrightrurrropAddrzSubBitOr)r7rrrs r{ visit_BinOpz8_signature_fromstr..RewriteSymbolics.visit_BinOps::di((DJJtz**EdCL11 !E3<9X9X !  $'37++ >|DJ$<===DGSW-- >|DJ$<===DGSY// >|DJ$<=== r}N)r3rpr-r rr)rsr{RewriteSymbolicsrsV % % % % % ' ' ' ' '     r}rc@ |}|rm|turd |}tj|}n1#t$r$t ddwxYw ||dS)Nrrr)_emptyrr literal_evalrr!r) name_node default_noderrrrrrrrrs r{pz_signature_fromstr..psz)$$  ]L66 ]//1177 EE *<88 ] ] ] !E!L!LS!Q!QRRX\\ ]))D$ERRRSSSSSs 1A .A9) fillvaluer4rr)&_parameter_clsrrr SyntaxErrorruModulerr!bodyrrrrrnrmr{NodeTransformerr rrr zip_longestPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDrBrvarargVAR_POSITIONAL KEYWORD_ONLYrZr kw_defaultsrN VAR_KEYWORDrZrAr)rrrcrrrrprogramrrrrrrrrHrr_self self_isbound self_ismodulerrrrrrrrrs ` @@@@@@@@@r{_signature_fromstrr3~s"I +1--:O^%9/)H4G7##  fcj ) )K=DDSIIJJJ AAJ OE FK#|T22K*d33  * /Kk&&((O      3.B,1TTTTTTTTTTTT AFK D((H  x4 @ @ @D'(.'d(<(<==33?D' $ $ $ $2D v} ' !&-  !DQV.0BCC g $ v|$ !&,! Z..D(    ] n  NN1    1 %%9+D%EEAJqM 3zSY 7 7 77sA AAct|s"td|t|dd}|s"t d|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!rrr3)rrrrcs r{_signature_from_builtinr6 s ! & &1##)6$<<11 1 *D11A M>EEdKKLLL c4N ; ;;r}c >d}t|s4t|rd}n"td|t |dd}|rt ||||S|j}|j} | j} | j } | j } | d| } | j }| | | |z}t||||}|j }|j}|rt|}nd}g}| |z }| }| d|D]U}|rt nt"}||t&}||||||r|d z}Vt+| |dD]_\}}|rt nt"}||t&}||||||| |r|d z}`| jt.zrL| | |z}||t&}||||t0|D]h}t&}|||t&}||t&}||||t2| i| jt4zrb| |z}| jt.zr|d z }| |}||t&}||||t6|||d t&| S) zCPrivate helper: constructs Signature for the given python function.FTrPr5Nrhrb)rrr=)rrrrr__validate_parameters__)rRrrr!rr3r"rrrco_posonlyargcountrr)rrr rrrnrrrBrrrrrr)rrrrirjrkis_duck_functionrcr func_code pos_count arg_names posonly_countr+keyword_only_count keyword_onlyrrrpos_default_countrnon_default_count posonly_leftrrroffsetrros r{_signature_from_functionrF s d  J %d + + J#  ;BB4HHII I*D11A@!#tQ???"I I%I%I0M:I:&J"4Yy3E'EEFL!$QYZZZK H$JMMJ!$55 L---.#/K5K __T622 ))DZ)-/// 0 0 0   A L"*->-?-?"@AA #/K5K __T622 ))DZ)-,4V,<>>> ? ? ?   A LJ&;%778 __T622 ))DZ)8::: ; ; ;66  ! nnT622G __T622 ))DZ)6,3555 6 6 6 6N*8..   *  QJE __T622 ))DZ)5777 8 8 8 3z!,6!B!B'7 9 9 99r})rrrirjrkc  tjt||||||}t|s"t d|t |tjr#||j }|rt|S|S|r7t|d}t |tjr ||S |j }|9t |ts"t d||Sn#t$rYnwxYw |j} t | tjr|| j} t%| | d}t'| jd} | jt.jur|St'|j} | r | | dusJ| f| z} || Sn#t$rYnwxYwt5|st7|rt9|||||| St;|rt=||| St |tjr ||j} t%| |Sd}t |t>r4tAt?|d }| ||}nWd}tA|d }tA|d}|j!D] }| d |j"vr|}n| d|j"vr|}n!| ||}||j!ddD]/} |j#}|rtI|||cS #t$rY,wxYwt>|j!vrb|j%tLj%ur-|j'tLj'ur|(tLStSd|nxt |tTsctAt?|d }|D ||}n7#tR$r*}d|}tS||d}~wwxYw||rt|S|St |tj+r$d|}tS|tSd|)zQPrivate helper function to get signature for arbitrary callable objects. )rrrirjrrkz{!r} is not a callable objectcVt|dpt|tjS)N __signature__)rrurrrs r{rz*_signature_from_callable.. s)'!_*E*E+C#-a1A#B#Br}rNz1unexpected object {!r} in __signature__ attributerrbr)rrirjrk)r__call__rlrr,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),rrrrrr!rurrrrr`rIrr_partialmethod partialmethodrrrrrrrr+rrRrrFrr6r~rrrmr5r3rrrl from_callablerrr)rrrrirjrkr_get_signature_ofrrLrfirst_wrapped_param sig_paramsrcallfactory_methodnewinitrtext_sigrr?s r{rr| s")*B6K/=(/'-'-)1 333 C==E7>>sCCDDD#u'((  --  *3// /J *S!C!CEEE c5+ , , *%$S)) )  ?c9-- - &s ---J       :*  mY%< = = :,+M,>??K(mWMMC"' (>(E(E(G(G"H"H"K "'9+CCC "3>#8#8#:#:;; &B+:a=@@@@13j@ {{j{999+ :      4#[4S99[(7E07QY[[[ [S!!F&vs6DFFF F#y())8''11 %k3777 C#tK. 2$s))ZHH  ##D))CC!N4S)DDC5c:FFD   ?yDM'A'A%(NE%* *E*E%)NE)''77 ; CRC( J JJ#6H J 2&$IIIIIJ&D3;&&LFO33K6>11!//777$BII#NNPPP5 6 6 . 2$s))ZHH   .''-- . . .3::3?? oo2- .   *3// /J#u011<CCCHHoo BII#NN O OOsN D DDG11 G>=G>=M M'&M' P Q&%Q  QceZdZdZdS)rz1A private marker - used in Parameter & Signature.Nr3rpr-r2rtr}r{rr> s;;;;r}rceZdZdZdS)rz6Marker object for Signature.empty and Parameter.empty.NrWrtr}r{rrB s@@@@r}rc.eZdZdZdZdZdZdZdZdZ dS) _ParameterKindzpositional-onlyzpositional or keywordzvariadic positionalr,zvariadic keywordct|j}t||}||_||_|Sr)r  __members__rrl_value_ description)rr^rzmembers r{rlz_ParameterKind.__new__M s8CO$$S%((( r}c|jSrrrs r{__str__z_ParameterKind.__str__T s yr}N) r3rpr-r(r)r+r,r.rlrartr}r{rZrZF sL'O3*N!L$Kr}rZceZdZdZdZeZeZe Z e Z e ZeZeeddZdZdZedZedZed Zed Zeeeed d Zd ZdZdZdZdS)raRepresents 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 _annotationrc t||_n!#t$rtd|dwxYw|turE|jtt fvr0d}||jj}t|||_||_ |turtdt|ts6dt|j }t||ddkr|ddri|jt kr0d }||jj}t|t"|_d |dd}t%|o |jt"u}|s|s"td |||_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 {}rbr+r=zLimplicit arguments must be passed as positional or keyword arguments, not {}z implicit{}z"{!r} is not a valid parameter name)rZrdrrrrr!r^rerfrurvr~r3risdigitrrrc isidentifierrc)r7rrrrr? is_keywords r{rzParameter.__init__~ s N'--DJJ N N NLdLLLMM M N & zo|<<<@jj!788 oo% % 6>>IJJ J$$$ !077T 8KLLCC.. 7c>>d122h..00> z333>jj!788 oo%)DJ&&tABBx00Dt__K;K)K  PT..00 PAHHNNOO O s5cXt||j|jf|j|jdfS)Nrerf)r~rcrdrerfrs r{ __reduce__zParameter.__reduce__ s6T TZ(!] $ 0223 3r}c:|d|_|d|_dS)Nrerfrlr7states r{ __setstate__zParameter.__setstate__ s!j)  /r}c|jSr)rcrs r{rzParameter.name zr}c|jSr)rers r{rzParameter.default s }r}c|jSr)rfrs r{rzParameter.annotation r}c|jSr)rdrs r{rzParameter.kind rsr})rrrrc|tur|j}|tur|j}|tur|j}|tur|j}t |||||S)z+Creates a customized copy of the Parameter.r)rrcrdrfrer~)r7rrrrs r{rzParameter.replace sh 5==:D 5==:D   )J e  mGtDzz$g*MMMMr}c|j}|j}|jtur(d|t |j}|jtur_|jtur)d|t|j}n(d|t|j}|tkrd|z}n|tkrd|z}|S)Nz{}: {}z{} = {}z{}={}rr) rrcrfrr!r&rerrr)r7r formatteds r{razParameter.__str__ syJ   6 ) )  '78H'I'IKKI = & &v--%,,YT]8K8KLL #NN9d4=6I6IJJ ? " "iII \ ! !y(Ir}cBd|jj|S)Nz <{} "{}">r!r5r3rs r{rrzParameter.__repr__ s!!$."94@@@r}cPt|j|j|j|jfSr)hashrrrrrs r{__hash__zParameter.__hash__ s!TY 4?DLIJJJr}c||urdSt|tstS|j|jko/|j|jko|j|jko|j|jkSNT)rurNotImplementedrcrdrerfr7others r{__eq__zParameter.__eq__ sp 5==4%++ "! ! ek)6 ek)6 /6 E$55 7r}N)r3rpr-r2r1rr(rr)rr+rr,rr.rrrrmrqrrrrrrrrarrrrrtr}r{rr^ sY*>I.O4-N+L*K E.4)))))V333 000XX  X X$% %NNNNN$,AAAKKK77777r}rc|eZdZdZdZdZedZedZedZ dZ dZ d Z d Z d Zd S) raResult 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"||_||_dSr)rr)r7r]rs r{rzBoundArguments.__init__ s"#r}c|jSr)rrs r{r]zBoundArguments.signature s r}cNg}|jjD]v\}}|jtt fvrn[ |j|}|jtkr||P| |f#t$rYnwxYwt|Sr) rrrrrrrrextendrr]r)r7rrrr5s r{rzBoundArguments.args s!%!;!A!A!C!C % % JzlM::: %nZ0 :00KK$$$$KK$$$$    T{{s B BBc:i}d}|jjD]w\}}|s$|jtt fvrd}n ||jvrd}+|s. |j|}|jtkr||b|||<h#t$rYtwxYw|Sr) rrrrrrrupdater])r7kwargskwargs_startedrrr5s r{rzBoundArguments.kwargs. s!%!;!A!A!C!C - - J! !:, !>>>%)NN!77)- !  -nZ0:--MM#&&&&*-F:&&     s B  BBc|j}g}|jjD]\}} ||||f$#t $rT|jtur|j}n$|jturd}n|jturi}nYh|||fYwxYwt||_dS)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. rtN) rrrrrr]rrrrrr)r7r new_argumentsrrvals r{apply_defaultszBoundArguments.apply_defaultsL sN  ?5;;== 2 2KD% 2$$dIdO%<==== 2 2 2=..-CCZ?22CCZ<//CCH$$dC[11111 2m,,sA  AB*B*)B*c||urdSt|tstS|j|jko|j|jkSr)rurrr]rrs r{rzBoundArguments.__eq__h sJ 5==4%00 "! !%/12%/1 3r}c:|d|_|d|_dS)Nrrrrros r{rqzBoundArguments.__setstate__p s -{+r}c |j|jdS)Nrrrs r{ __getstate__zBoundArguments.__getstate__t s"oDNKKKr}cg}|jD].\}}|d||/d|jjd|S)Nz{}={!r}z <{} ({})>r#)rrrr!r5r3rB)r7rr5rzs r{rrzBoundArguments.__repr__w sr...00 6 6JC KK ((e44 5 5 5 5!!$."9499T??KKKr}N)r3rpr-r2r1rrr]rrrrrqrrrrtr}r{rr s ;I$$$XX,X:---8333,,,LLLLLLLLr}rceZdZdZdZeZeZe Z de dddZ e dddddd Z ed Zed Zeed d ZdZdZdZdddZdZdZdZdZdZdZdS)raA 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 _parametersNTr8c4|t}n|rt}t}d}|D]}|j}|j} ||kr1d} | |j|j} t | ||kr|}|ttfvr$|jtur|rd} t | nd}| |vr$d| } t | ||| <ntd|D}tj ||_ ||_ dS)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}c3(K|] }|j|fVdSrrrxrs r{rz%Signature.__init__.. s)$Q$QUej%%8$Q$Q$Q$Q$Q$Qr})rfrrrr!r^rrrrrMappingProxyTyperr) r7rrr9rtop_kind seen_defaultrrrr?s r{rzSignature.__init__ sY   ]]FF&& R$+$ '))E :D :Dh("jj)=)-)9;;(oo-#' 02HIII =F22+6'1&0oo 5 6,0Lv~~>EEdKK(oo-#(F4LL?)B%$Q$Qj$Q$Q$QQQ 1&99"3r}Ffollow_wrappedrirjrkc,t||||||S)z3Constructs Signature for the given callable object.)rrrirjrk)r)rrrrirjrks r{rMzSignature.from_callable s.(C>L07QY[[[ [r}c|jSr)rrs r{rzSignature.parameters rvr}c|jSrrrs r{rzSignature.return_annotation s &&r})rrc|tur|j}|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~)r7rrs r{rzSignature.replace sZ   //11J  % % $ 7 tDzz*,=??? ?r}ctd|jD}d|jD}|||jfS)Nc3:K|]}|jtk|VdSr)rrrs r{rz(Signature._hash_basis.. s:== % m ; ; ; ; ; ;==r}c>i|]}|jtk|j|Srt)rrrrs r{r|z)Signature._hash_basis.. s5HHHE+0:+F+Fj%+F+F+Fr})rrrr)r7r kwo_paramss r{ _hash_basiszSignature._hash_basis s|==$/*@*@*B*B=====HHT_5K5K5M5MHHH z4#999r}c|\}}}t|}t|||fSr)r frozensetrr~)r7rrrs r{rzSignature.__hash__ sJ040@0@0B0B- -z002233 VZ):;<<N0N0N'BII$)JJ00116:;-4Iej))/%OOO#$CDD$NOU!% ;% ;% ;#; ,,E z_44v-- :)999#@C"%***"<"?A Ar}c |d|_dSrrros r{rqzSignature.__setstate__ s"'(<"=r}cBd|jj|S)Nz<{} {}>r|rs r{rrzSignature.__repr__ s 7>>>r}cDg}d}d}|jD]}t|}|j}|tkrd}n|r|dd}|t krd}n$|tkr|r|dd}|||r|ddd |}|j tur,t|j }|d|z }|S)NFTrrz({})r#z -> {}) rrrvrrrrrr!rBrrr&) r7r render_pos_only_separatorrender_kw_only_separatorrrzrrenderedannos r{razSignature.__str__ sC$)!#' _++-- % %EE I:D''',0))* 2 c""",1)&&,1((&&+C& c""",1( MM) $ $ $ $ $  MM#   ==6!2!233  ! / /#D$:;;D -- -Hr}r)r3rpr-r2r1rr"rrrrrrrMrrrrrrrrrrrrmrqrrrartr}r{rr~ s,6IN) E24V)-2424242424h%)4u[[[[[[  X ''X'%*U ? ? ? ? ?:::=== 999.3A:A:A:A:A:F(((666AAA >>>???+++++r}rrc@t|||||S)z/Get a signature object for the passed callable.r)rrM)rrrirjrks r{r]r] s-  " "3~+26H # V VVr}cddl}ddl}|}|dd|dddd |}|j}|d \}}} |j|x}} no#t$rb} d |t| j | } t| tj tjdYd} ~ nd} ~ wwxYw|r,|d} | }| D]} t#|| }| j tjvr/tdtj tjd|jr?td |td t)| td | j|| urltd t-| jt1| dr'td | jnF t5|\}}td |n#t$rYnwxYwtddStt7|dS)z6 Logic for inspecting an object given at command line rbNrzCThe 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 {} ({}: {}))r~rr+z#Can't get info for builtin modules.r=z Target: {}z Origin: {}z Cached: {}z Loader: {}__path__zSubmodule search path: {}zLine: {}r<)argparserXArgumentParser add_argument parse_argsr partition import_modulerr!r~r3printrstderrexitr.rbuiltin_module_namesdetailsrD __cached__rrfrrr%rC)rrXparserrtargetmod_name has_attrsattrsrrrr?partspart__rs r{_mainr sOOO  $ $ & &F 9:::  k, HJJJ     D [F!'!1!1#!6!6Hi.y.x888ff ,33H48II4F4799 c ####  % C   % %D#t$$CC #222 3#*EEEE   | l!!&))*** l!!-"7"788999 l!!&"344555 &== ,%%d6+<&=&=>> ? ? ?vz** K188IIJJJ 1'__ Fj''//0000     d  inns+B DAC<<D%J J'&J'rKr)F)r=)rt)T)TNNF)r2 __author____all__rrrcollections.abcrenumimportlib.machineryrXrrprUrrrrrrrxkeywordrcoperatorrdrerfrimod_dictCOMPILER_FLAG_NAMESrrrr r)rZrLrWrXrPrrVrUrRrrTrOrIrHrSrNrJr\rQrMrKrYr[rGrr=r>rr"rAr`rFr/r9r5r#r6r@rDr*ryr|r?rr NodeVisitorrr%r2rrr.rErCrar0rr+rr8rr,r&r'rvr(r2r@r/rr1rer!r{rxr7r<_fieldsrrrBr;r$r^r_rrrrrrrr-rrrrr:r9rr r rr4r3WrapperDescriptorTyperrrrrrrrrrr3r6rFrrrIntEnumrZr(rr)rr+rr,rr.rrrrr]rr3rtr}r{rs\ @9 a a a H    //////// 799  # ) ) + +DAqHUQYq(%)ppppph000$$$000AAA( ? ? ? 75())>>>> 75())>>>> 2 2 2 , , ,------333888333"333;;;333 / / /...2999777(((0(((T3333 : : : : J{$E F F ppph !!!!!H000 <<<|&   :,,,8   28888 ,,,,^     )   3?>B0B0B0H+%+%+%Z"!!!!!!!44444444l $ $ $000*++++6 J{$: ; ; 8888jMOO Z<Z<Z ? ?999    ""9"9 8 8 ? ? ((((.777 DDD*:::xj(LMM 141414jZ &S T T  - - - - - - - -777OOO)A)A)A)AV Z j93D&D E E  @ @ @ @ @ @ @ @        CCC55556666 FHH 333444   '0----d    $&  ! $   $"7!3!;!57    I?I?I?I?X***4 # # #GGG2EAEAEAPL8L8L8L8^ < < < < 8