
    ii              
      6   % S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKJr	  S SKJ
r
JrJrJr  S SKJr  S SKJrJr  S SKJr  S SKJrJr  S S	KJrJrJr  S S
KJrJrJrJrJ r   S SK!J"r"J#r#  S SK$J%r%  S SK&J'r'  S SK(J)r)J*r*J+r+J,r,J-r-J.r.JrJ/r/J0r0J1r1J2r2  \(       a  S SK3J4r4  S SK5J6r6  S SK7J8r8J9r9  S SKJ:r:  S\;S'    S SK<r<\\<4r=\
R~                  r@SSSSSSSSS.                   SS jjr " S S5      rA\	R                  \R                  \	R                  \R                  \	R                  \R                  \	R                  \R                  \	R                  \R                  0rLSS.       S S jjrMSS.S!S jjrN\R                  \R                  \R                  S.R                  5        V VVs0 s H'  u  p\=  H  n\S" X 5      (       d  M  \T" X 5      U_M     M)     snnn rUSS.       S"S jjrVSS.S!S jjrWg! \> a    \4r= GNQf = fs  snnn f )#    )annotationsN)	Parameter)	Signaturecleandocgetsourcelinesunwrap)	signature)TYPE_CHECKINGAny)
ObjectNode)LinesCollectionModulesCollection)KindParameterKindTypeParameterKind)Expr	ExprBinOpExprSubscript	ExprTuplesafe_get_annotation)
Extensionsload_extensions)dynamic_import)logger)Alias	AttributeClass	DocstringFunctionModuler   
Parameters	TypeAliasTypeParameterTypeParameters)Sequence)Path)DocstringOptionsDocstringStyle)Parserztuple[types.ModuleType, ...]_TYPING_MODULES)filepathimport_paths
extensionsparentdocstring_parserdocstring_optionslines_collectionmodules_collectionc               b    [        U UU=(       d
    [        5       UUUUUS9R                  U5      $ )a  Inspect a module.

Sometimes we cannot get the source code of a module or an object,
typically built-in modules like `itertools`.
The only way to know what they are made of is to actually import them and inspect their contents.

Sometimes, even if the source code is available,
loading the object is desired because it was created or modified dynamically,
and our static agent is not powerful enough to infer all these dynamic modifications.
In this case, we load the module using introspection.

Griffe therefore provides this function for dynamic analysis.
It uses a [`NodeVisitor`][ast.NodeVisitor]-like class, the [`Inspector`][griffe.Inspector],
to inspect the module with [`inspect.getmembers()`][inspect.getmembers].

The inspection agent works similarly to the regular [`Visitor`][griffe.Visitor] agent,
in that it maintains a state with the current object being handled, and recursively handle its members.

Important:
    This function is generally not used directly.
    In most cases, users can rely on the [`GriffeLoader`][griffe.GriffeLoader]
    and its accompanying [`load`][griffe.load] shortcut and their respective options
    to load modules using dynamic analysis.

Parameters:
    module_name: The module name (as when importing [from] it).
    filepath: The module file path.
    import_paths: Paths to import the module from.
    extensions: The extensions to use when inspecting the module.
    parent: The optional parent of this module.
    docstring_parser: The docstring parser to use. By default, no parsing is done.
    docstring_options: Docstring parsing options.
    lines_collection: A collection of source code lines.
    modules_collection: A collection of modules.

Returns:
    The module, with its members populated.
)r/   r0   r1   r2   )	Inspectorr   
get_module)	module_namer+   r,   r-   r.   r/   r0   r1   r2   s	            [/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/agents/inspector.pyinspectr8   7   s>    d 'o')+)-	 j	    c                  H  ^  \ rS rSrSr     S                 SU 4S jjjrSS jrSS jrSS S jjrS!S jr	S!S jr
S!S	 jrS!S
 jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrS!S jrSS"S jjrS!S jrS!S jrSS#S jjrSrU =r$ )$r4   u   zrThis class is used to instantiate an inspector.

Inspectors iterate on objects members to extract data from them.
c	                   > [         T	U ]  5         Xl         X l         X0l         X@l         SU l         XPl         U=(       d    0 U l         U=(       d
    [        5       U l
         U=(       d
    [        5       U l        g)a  Initialize the inspector.

Parameters:
    module_name: The module name.
    filepath: The optional filepath.
    extensions: Extensions to use when inspecting.
    parent: The module parent.
    docstring_parser: The docstring parser to use.
    docstring_options: Docstring parsing options.
    lines_collection: A collection of source code lines.
    modules_collection: A collection of modules.
N)super__init__r6   r+   r-   r.   currentr/   r0   r   r1   r   r2   )
selfr6   r+   r-   r.   r/   r0   r1   r2   	__class__s
            r7   r>   Inspector.__init__{   s{    . 	 +%-#&04%+='+1@P*3D3J,1A1V_EV05G5^K\K^&r9   c                     [        UR                  SS 5      nUc  g  [        U5      n[        UU R                  U R                  S9$ ! [         a     g f = f! [         a     g f = f)N__doc__)parserparser_options)getattrobj	Exceptionr   AttributeErrorr   r/   r0   )r@   nodevaluecleaneds       r7   _get_docstringInspector._get_docstring   s~    	DHHi6E =	 uoG ((11
 	
  		  		s"   A A 
AA
A%$A%c                   U R                   (       a  U R                   U R                  ;  a  g [        UR                  5      u  p#X3SR                  U5      R                  5       R                  S5      -   4$ ! [        [
        4 a     gf = f)N)NN 
)	r+   r1   r   rH   OSError	TypeErrorjoinrstripcount)r@   rK   lineslinenos       r7   _get_linenosInspector._get_linenos   sw    }}T5J5J J	*4884ME  5 5 7 = =d CCCC # 		s   A7 7B
	B
c                   U R                   nU R                  b  U R                  R                   SU 3n[        U=(       d    S5      nU R                  (       a  U R                  R                  n[        UR                  S5      5       H  nUR                  nM     U R                  R                  S:X  a  UR                  nX1;  a  UR                  SU5        [        X!5      nSnU R                  b6  U R                  R                  R                  S5       H  n[        SXvS9nM     [        XPR                   US9nU R                  U5        U R                  R                  $ )a  Build and return the object representing the module attached to this inspector.

This method triggers a complete inspection of the module members.

Parameters:
    import_paths: Paths replacing `sys.path` to import the module.

Returns:
    A module instance.
N. r>   r   )namer.   )r.   )r6   r.   pathlistr+   rangerW   steminsertr   splitr   r8   r?   module)	r@   r,   import_pathparent_path_rL   parent_nodepartmodule_nodes	            r7   r5   Inspector.get_module   s+    &&;;"![[--.a}=K L.B/ ==--..K;,,S12)00 3 }}!!Z/)00.##A{3{9
 ;;"((..s3(DM 4 (8(8M[!||"""r9   c                X    [        U SUR                   3U R                  5      " U5        g)zXExtend the base inspection with extensions.

Parameters:
    node: The node to inspect.
inspect_N)rG   kindgeneric_inspectr@   rK   s     r7   r8   Inspector.inspect   s&     	,d.B.BCDIr9   c                d   UR                    GH  nUR                  =n(       Gav  UR                  (       Ga  X0R                  R                   SUR
                   3:X  a  [        UR                  S5      (       d  [        R                  " SU5        [        UR
                  SU R                  R                  U R                  U R                  U R                  U R                  U R                   S9nUR#                  U5        U R                  R%                  UR
                  UR                  R                  5        GM2  GM5  ['        UR
                  USS9nU R                  R%                  UR
                  U5        U R                  R)                  SXQU S	9  GM  U R+                  U5        GM     g)
z`Extend the base generic inspection with extensions.

Parameters:
    node: The node to inspect.
r]   __file__z;Module %s is not discoverable on disk, inspecting right nowN)r+   r.   r-   r/   r0   r1   r2   dynamic)analysison_alias_instance)aliasrK   agent)childrenalias_target_path	is_moduler?   r`   r_   hasattrrH   r   debugr4   rf   r-   r/   r0   r1   r2   inspect_module
set_memberr   callr8   )r@   rK   childtarget_path	inspectorry   s         r7   rq   Inspector.generic_inspect  sF    ]]E#555{5 ???{9J9J8K1UZZL6Y'Y"599j99%bdop$-!JJ%)#'<<#6#6'+-1-B-B.2.D.D-1-B-B/3/F/F	%	 "007//

I<M<M<T<TU :  "%**kINELL++EJJ>OO(()<E\`(aU#; #r9   c           
        U R                   R                  SXS9  U R                   R                  SXS9  [        U R                  U R                  U R
                  U R                  U5      U R                  U R                  SS9=U l	        nU R                   R                  SXU S9  U R                   R                  SXU S	9  U R                  U5        U R                   R                  S
XU S9  U R                   R                  SXU S	9  g)z>Inspect a module.

Parameters:
    node: The node to inspect.
on_noderK   rz   on_module_noderv   )r_   r+   r.   	docstringr1   r2   rw   on_instancerK   rH   rz   on_module_instance)rK   modrz   
on_memberson_module_membersN)r-   r   r    r6   r+   r.   rN   r1   r2   r?   rq   )r@   rK   rf   s      r7   r   Inspector.inspect_module,  s     	YT>-DE &!!]];;))$/!22#66!
 	
v 	]N1PTUT"\M0ttTr9   c                l   U R                   R                  SXS9  U R                   R                  SXS9  / nUR                  R                   H8  nU[        L a  M  UR                  UR                   SUR                   35        M:     U R                  U5      u  pE[        UR                  U R                  U5      U[        [        UR                  U R                  UR                  S96 UUSS9nU R                  R                  UR                  U5        X`l        U R                   R                  SXU S	9  U R                   R                  S
XU S9  U R!                  U5        U R                   R                  SXU S	9  U R                   R                  SXU S9  U R                  R"                  U l        g)z=Inspect a class.

Parameters:
    node: The node to inspect.
r   r   on_class_noder]   r.   memberrv   )r_   r   basestype_parametersrY   	endlinenorw   r   r   on_class_instance)rK   clsrz   r   on_class_membersN)r-   r   rH   	__bases__objectappend
__module____qualname__rZ   r   r_   rN   r$   _convert_type_parametersr?   r   rq   r.   )r@   rK   r   baserY   r   class_s          r7   inspect_classInspector.inspect_classC  s    	YT>_4DHH&&Dv~LLDOO,Ad.?.?-@AB '
 !--d3))$/*,DTXXVZVbVbkoktkt,uv
 			62]N0ttTT"\M/ddS||**r9   c                *    U R                  US15        g)zEInspect a static method.

Parameters:
    node: The node to inspect.
staticmethodNhandle_functionrr   s     r7   inspect_staticmethodInspector.inspect_staticmethode  s     	TN#34r9   c                *    U R                  US15        g)zDInspect a class method.

Parameters:
    node: The node to inspect.
classmethodNr   rr   s     r7   inspect_classmethodInspector.inspect_classmethodm  s     	TM?3r9   c                *    U R                  US15        g)zIInspect a method descriptor.

Parameters:
    node: The node to inspect.
zmethod descriptorNr   rr   s     r7   inspect_method_descriptor#Inspector.inspect_method_descriptoru  s     	T$7#89r9   c                *    U R                  US15        g)zFInspect a builtin method.

Parameters:
    node: The node to inspect.
builtinNr   rr   s     r7   inspect_builtin_method Inspector.inspect_builtin_method}       	TI;/r9   c                &    U R                  U5        g)z>Inspect a method.

Parameters:
    node: The node to inspect.
Nr   rr   s     r7   inspect_methodInspector.inspect_method       	T"r9   c                *    U R                  US15        g)zAInspect a coroutine.

Parameters:
    node: The node to inspect.
asyncNr   rr   s     r7   inspect_coroutineInspector.inspect_coroutine  s     	TG9-r9   c                *    U R                  US15        g)zHInspect a builtin function.

Parameters:
    node: The node to inspect.
r   Nr   rr   s     r7   inspect_builtin_function"Inspector.inspect_builtin_function  r   r9   c                &    U R                  U5        g)z@Inspect a function.

Parameters:
    node: The node to inspect.
Nr   rr   s     r7   inspect_functionInspector.inspect_function  r   r9   c                ,    U R                  USS15        g)zGInspect a cached property.

Parameters:
    node: The node to inspect.
cachedpropertyNr   rr   s     r7   inspect_cached_property!Inspector.inspect_cached_property  s     	THj#9:r9   c                *    U R                  US15        g)z@Inspect a property.

Parameters:
    node: The node to inspect.
r   Nr   rr   s     r7   inspect_propertyInspector.inspect_property       	TJ<0r9   c                *    U R                  US15        g)zJInspect a get/set descriptor.

Parameters:
    node: The node to inspect.
r   Nr   rr   s     r7   inspect_getset_descriptor#Inspector.inspect_getset_descriptor  r   r9   c                b   U R                   R                  SXS9  U R                   R                  SXS9   [        UR                  5      n[	        UR
                  R                  5        Vs/ s H!  n[        X@R                  UR                  S9PM#     sn6 nUR                  nU[        L a  SO[        X`R                  UR                  S9nU R                  U5      u  pU=(       d
    [        5       nSU;   a)  [!        UR                  SUU R#                  U5      UU	SS9n
OV[%        UR                  UU['        [)        UR                  U R                  UR                  S96 U R#                  U5      UU	SS	9n
U
=R*                  U-  sl        U R                  R-                  UR                  U
5        U R                   R                  S
XU S9  U
R.                  (       a  U R                   R                  SXU S9  gU R                   R                  SXU S9  gs  snf ! [         a    SnSn GN`f = f)zmHandle a function.

Parameters:
    node: The node to inspect.
    labels: Labels to add to the data object.
r   r   on_function_noder   Nr   rv   )r_   rL   
annotationr   rY   r   rw   )r_   
parametersreturnsr   r   rY   r   rw   r   r   on_attribute_instancerK   attrrz   on_function_instance)rK   funcrz   )r-   r   getsignaturerH   r!   r   values_convert_parameterr?   r_   return_annotation_empty_convert_object_to_annotationrI   rZ   setr   rN   r   r$   r   labelsr   is_attribute)r@   rK   r   r	   	parameterr   r   r   rY   r   rH   s              r7   r   Inspector.handle_function  s    	YT>/dG	$TXX.I $ &/%9%9%@%@%B%B	 'ydiiX%BJ !* ; ; %. 23D\\bfbkbkl  !--d3 35YY"--d3#"C YY% .-dhht||TXT]T]^! --d3#"C 	

f
		3/]dKOO  !8tUY ZOO  !7dTX Y[  	 JG		s   H ,(HH.-H.c                l   U R                   R                  SXS9  U R                   R                  SXS9  U R                  U5      u  p#[        UR                  [        UR                  R                  U R                  UR                  S9UU[        [        UR                  U R                  UR                  S96 U R                  U5      U R                  SS9nU R                  R                  UR                  U5        U R                   R                  SXU S9  U R                   R                  S	XU S
9  g)zBInspect a type alias.

Parameters:
    node: The node to inspect.
r   r   on_type_alias_noder   rv   )r_   rL   rY   r   r   r   r.   rw   r   r   on_type_alias_instance)rK   
type_aliasrz   N)r-   r   rZ   r"   r_   _convert_type_to_annotationrH   	__value__r?   r$   r   rN   r   )r@   rK   rY   r   r   s        r7   inspect_type_aliasInspector.inspect_type_alias  s    	YT>1I --d3-dhh.@.@^b^g^gh*,DTXXVZVbVbkoktkt,uv))$/<<	

 			:6]TR5D_cdr9   c                &    U R                  U5        g)zBInspect an attribute.

Parameters:
    node: The node to inspect.
N)handle_attributerr   s     r7   inspect_attributeInspector.inspect_attribute  s     	d#r9   c                   U R                   R                  SXS9  U R                   R                  SXS9  U R                  n[        5       nUR                  [
        R                  L a  UR                  S5        OzUR                  [
        R                  L a  UR                  S5        OKUR                  [
        R                  L a.  UR                  S:w  a  gUR                  nUR                  S5         [        UR                  5      n U R                  U5      n[!        UR                  UUUS	S
9nU=R"                  U-  sl        UR%                  UR                  U5        UR                  S:X  a  ['        UR                  5      Ul        U R                   R                  SXU S9  U R                   R                  SXU S9  g! [         a    Sn Nf = f! [         a    Sn Nf = f)ziHandle an attribute.

Parameters:
    node: The node to inspect.
    annotation: A potential annotation.
r   r   on_attribute_nodezmodule-attributezclass-attributer>   Nzinstance-attributerv   )r_   rL   r   r   rw   __all__r   r   r   r   )r-   r   r?   r   rp   r   MODULEaddCLASSFUNCTIONr_   r.   reprrH   rI   rN   r   r   r   ra   exports)r@   rK   r   r.   r   rL   r   	attributes           r7   r   Inspector.handle_attribute   s    	YT>0tH 5;;$++%JJ)*[[DJJ&JJ()[[DMM){{j(]]FJJ+,	NE	++D1I !
	 	F"$))Y/99	!!$((^FN]DQ44W[\)  	E	  	I	s$   5G G GGG&%G&)	r?   r0   r/   r-   r+   r1   r6   r2   r.   )NNNNN)r6   strr+   Path | Noner-   r   r.   Module | Noner/   DocstringStyle | Parser | Noner0   DocstringOptions | Noner1   LinesCollection | Noner2   ModulesCollection | NonereturnNone)rK   r   r  zDocstring | None)rK   r   r  z#tuple[int, int] | tuple[None, None])N)r,   Sequence[str | Path] | Noner  r    )rK   r   r  r  )rK   r   r   z
set | Noner  r  )rK   r   r   str | Expr | Noner  r  )__name__r   r   __firstlineno__rD   r>   rN   rZ   r5   r8   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classcell__)rA   s   @r7   r4   r4   u   s     !%;?59377;2'2' 2' 	2'
 2' 92' 32' 12' 52' 
2' 2'h
,D.#`J#$JU. +D54:0#.0#;11@ZDe2$.] .]r9   r4   r   c               `   U R                   nU R                  [        L a  S O[        U R                  XS9n[        U R
                     nU R                  [        L a  S nOG[        U R                  S5      (       a  U R                  R                  nO[        U R                  5      n[        X4XVS9$ )Nr   r
  )r   rp   default)r_   r   r   r   _parameter_kind_maprp   r  r~   r
  r   r   )r   r.   r   r_   r   rp   r  s          r7   r   r   Z  s     >>D 6) 	*9+?+?^ 
 y~~.DF"	""J	/	/##,,y(()TtMMr9   c                  [        U [        5      (       a  U nO3[        U 5      n[        U S5      (       a  SU;   a  U R                  OUnOUn [        USS[        R                  SS9n[        UR                  XS9$ ! [         a    U s $ f = f)Nr
  <evalz<>   )modefilenameflagsoptimizer  )
isinstancer   r   r~   r
  compileastPyCF_ONLY_ASTSyntaxErrorr   body)rH   r.   r   r   obj_reprannotation_nodes         r7   r   r   q  s     #s
 93
## *-hJ!J!*6DPSPaPalmn 33VKK  
s   A< <B
B)TypeVarTypeVarTuple	ParamSpecc                  [        U 5      n [        U S5      (       d  / $ / nU R                   H  n[        USS 5      nUb
  [	        XQUS9n[        USS5       Vs/ s H  n[	        XaUS9PM     nn[        USS 5      " 5       (       a  [	        UR
                  UUS9nOS nUR                  [        UR                  [        [        U5         UU=(       d    S US95        M     U$ s  snf )	N__type_params__	__bound__r   __constraints__r^   has_defaultc                     g)NFr^   r^   r9   r7   <lambda>*_convert_type_parameters.<locals>.<lambda>  s    %r9   )rp   boundconstraintsr  )r   r~   r&  rG   r   __default__r   r#   r
  _type_parameter_kind_maptype)	rH   r.   r   r   type_parameterr-  
constraintr.  r  s	            r7   r   r     s    +C3)**	O--T:/VTE &n6GL)
L
 (
&QL 	 )

 >=-@BB1**G G''-d>.BC'/4	
% .8 1)
s   C$c          	     H   [         R                  " U 5      nUc
  [        XUS9$ [         R                  " U 5       Vs/ s H  n[	        XAUS9PM     nnU[
        R                  L a  [        R                  " S U5      $ [	        X1US9nUc  g [        U[        USS95      $ s  snf )Nr   c                    [        U SU5      $ )N|)r   )leftrights     r7   r+  -_convert_type_to_annotation.<locals>.<lambda>  s    IdC4Or9   T)implicit)typing
get_originr   get_argsr   types	UnionType	functoolsreducer   r   )rH   r.   r   originargargss         r7   r   r     s    s#F~,SOO SYRaRabeRf)Rf3#CvFRf 	 )   OQUVV(vNF~4$!?@@)s   B)r6   r   r+   r   r,   r  r-   zExtensions | Noner.   r  r/   r  r0   r  r1   r  r2   r  r  r    )r   SignatureParameterr.   Module | Classr   
str | Noner  r   )rH   r   r.   rF  r   rG  r  r	  )rH   r   r.   rF  r   rG  r  zlist[TypeParameter])X
__future__r   r  r@  sysr>  r;  r8   r   rE  r   r   r   r   r	   r   r
   r   %griffe._internal.agents.nodes.runtimer   griffe._internal.collectionsr   r   griffe._internal.enumerationsr   r   r   griffe._internal.expressionsr   r   r   r   r    griffe._internal.extensions.baser   r   griffe._internal.importerr   griffe._internal.loggerr   griffe._internal.modelsr   r   r   r   r   r    r!   r"   r#   r$   collections.abcr%   pathlibr&   #griffe._internal.docstrings.parsersr'   r(   r)   __annotations__typing_extensionsr*   ImportErroremptyr   r4   POSITIONAL_ONLYpositional_onlyPOSITIONAL_OR_KEYWORDpositional_or_keywordVAR_POSITIONALvar_positionalKEYWORD_ONLYkeyword_onlyVAR_KEYWORDvar_keywordr  r   r   type_vartype_var_tuple
param_specitemsr~   rG   r0  r   r   )r   rL   rf   s   000r7   <module>rg     s   # 
  
   3 ? ? - % < K P P g g H 4 *    (T4- -2 01O	 !04$( 7;15/337;; ; .	;
 "; ; 5; /; -; 1; ;|Y] Y]z &&(E(E,,m.Q.Q%%}'C'C##]%?%?""M$=$=  	N!N N 	N
 N. ]a L6 %--)88&11 eg		
 "v !GF5  " 	   	(	( ( 	(
 (V [_ A Ac   iO t	s   7H 7HH	HH