
    im]                       % S SK J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
  S SKJr  S SKJr  S SKJrJrJr  S SKJrJr  S S	KJr  S S
KJr  \(       a4  S SKrS SKJr  S SKJr  S SK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+   " S S\,5      r- " S S\-S9r.\\/\0\/\4   \.\,\.   4   r1  " S S5      r2SS1r3S\4S'    SS jr5    S S jr6S!S jr7g)"    )annotationsN)suppress)module_from_specspec_from_file_location)isclass)Path)TYPE_CHECKINGAnyUnion)ast_childrenast_kind)ExtensionNotLoadedError)dynamic_import)
ModuleType)	Inspector)
ObjectNode)Visitor)GriffeLoader)Alias	AttributeClassFunctionModuleObject	TypeAliasc                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )_ExtensionMetaclass    z Metaclass for Griffe extensions.c                L  > SU;   a  [         R                  " S[        SS9  SU;   aN  [        R                  " US   5      R
                  nSU;   d  SU;   a  SUS	'   [         R                  " S
[        SS9  SU;   a  [         R                  " S[        SS9  [        TU ]  XX#5      $ )Non_package_loadedzHThe `on_package_loaded` event is deprecated and renamed to `on_package`.   )
stacklevelon_aliasnodeagentT__old_on_aliaszThe `on_alias` event is now a load event and receives the `alias` and `loader` parameters. It doesn't receive the `node` or `agent` parameters anymore. Please use the new `on_alias` signature, or rename your hook to `on_alias_instance`.   on_wildcard_expansionzThe `on_wildcard_expansion` event is deprecated. Instead, hook onto the `on_alias` event and check for aliases' `wildcard_imported` boolean attribute.)warningswarnDeprecationWarninginspect	signature
parameterssuper__new__)clsnamebasesattrsr.   	__class__s        Z/home/james-whalen/.local/lib/python3.13/site-packages/griffe/_internal/extensions/base.pyr0   _ExtensionMetaclass.__new__#   s    %'MMZ"
  **5+<=HHJ#w*'<*.&'k '  #e+MMP # ws%77     )r2   strr3   ztuple[type, ...]r4   zdict[str, Any]returnr   )__name__
__module____qualname____firstlineno____doc__r0   __static_attributes____classcell__)r5   s   @r6   r   r       s    *8 8r8   r   c                     \ rS rSrS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 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          S0S jrS1S jrS2S jr Sr!g )3	Extension@   z!Base class for Griffe extensions.c                D    [        U S[        U5       3S 5      " U5        g)z8Visit a node.

Parameters:
    node: The node to visit.
visit_c                    g Nr9   _s    r6   <lambda>!Extension.visit.<locals>.<lambda>I   s    4r8   N)getattrr   selfr$   s     r6   visitExtension.visitC   s!     	x~./@Fr8   c                J    [        U5       H  nU R                  U5        M     g)zPVisit children nodes.

Parameters:
    node: The node to visit the children of.
N)r   rQ   rP   r$   childs      r6   generic_visitExtension.generic_visitK   s     "$'EJJu (r8   c                F    [        U SUR                   3S 5      " U5        g)z<Inspect a node.

Parameters:
    node: The node to inspect.
inspect_c                    g rI   r9   rJ   s    r6   rL   #Extension.inspect.<locals>.<lambda>Z   s    r8   N)rN   kindrO   s     r6   r,   Extension.inspectT   s      	,n=dCr8   c                r    UR                    H'  nUR                  (       a  M  U R                  U5        M)     g)z`Extend the base generic inspection with extensions.

Parameters:
    node: The node to inspect.
N)childrenalias_target_pathr,   rT   s      r6   generic_inspectExtension.generic_inspect\   s*     ]]E***U# #r8   c                   g)zpRun when visiting a new node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
Nr9   rP   r$   r%   kwargss       r6   on_nodeExtension.on_nodef       r8   c                   g)a  Run when an Object has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    obj: The object instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rP   r$   objr%   re   s        r6   on_instanceExtension.on_instancem   rh   r8   c                   g)a_  Run on objects (every kind) once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    obj: The object instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   rk   loaderre   s       r6   	on_objectExtension.on_object   rh   r8   c                   g)a  Run when members of an Object have been loaded.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    obj: The object instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rj   s        r6   
on_membersExtension.on_members   rh   r8   c                   g)zRun when visiting a new module node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rd   s       r6   on_module_nodeExtension.on_module_node   rh   r8   c                   g)a  Run when a Module has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    mod: The module instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rP   r$   modr%   re   s        r6   on_module_instanceExtension.on_module_instance   rh   r8   c                   g)aR  Run on modules once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    mod: The module instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   rz   ro   re   s       r6   	on_moduleExtension.on_module   rh   r8   c                   g)a  Run when members of a Module have been loaded.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    mod: The module instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   ry   s        r6   on_module_membersExtension.on_module_members   rh   r8   c                   g)zRun when visiting a new class node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rd   s       r6   on_class_nodeExtension.on_class_node   rh   r8   c                   g)a  Run when a Class has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    cls: The class instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rP   r$   r1   r%   re   s        r6   on_class_instanceExtension.on_class_instance   rh   r8   c                   g)aQ  Run on classes once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    cls: The class instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   r1   ro   re   s       r6   on_classExtension.on_class   rh   r8   c                   g)a  Run when members of a Class have been loaded.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    cls: The class instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   r   s        r6   on_class_membersExtension.on_class_members  rh   r8   c                   g)zRun when visiting a new function node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rd   s       r6   on_function_nodeExtension.on_function_node#  rh   r8   c                   g)a  Run when a Function has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    func: The function instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   )rP   r$   funcr%   re   s        r6   on_function_instanceExtension.on_function_instance,  rh   r8   c                   g)aW  Run on functions once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    func: The function instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   r   ro   re   s       r6   on_functionExtension.on_functionB  rh   r8   c                   g)zRun when visiting a new attribute node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rd   s       r6   on_attribute_nodeExtension.on_attribute_nodeO  rh   r8   c                   g)a  Run when an Attribute has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    attr: The attribute instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   )rP   r$   attrr%   re   s        r6   on_attribute_instanceExtension.on_attribute_instanceX  rh   r8   c                   g)aY  Run on attributes once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    attr: The attribute instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   r   ro   re   s       r6   on_attributeExtension.on_attributen  rh   r8   c                   g)zRun when visiting a new type alias node during static/dynamic analysis.

Parameters:
    node: The currently visited node.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   rd   s       r6   on_type_alias_nodeExtension.on_type_alias_node{  rh   r8   c                   g)a  Run when a TypeAlias has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    type_alias: The type alias instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
Nr9   )rP   r$   
type_aliasr%   re   s        r6   on_type_alias_instance Extension.on_type_alias_instance  rh   r8   c                   g)ab  Run on type aliases once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    type_alias: The type alias instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   r   ro   re   s       r6   on_type_aliasExtension.on_type_alias  rh   r8   c               T    [        U SS5      (       a  U R                  " SXUS.UD6  gg)a  Run when an Alias has been created.

Warning:
    This method runs while the object tree is still being constructed:
    data might be incomplete (class inheritance, alias resolution, etc.).
    Only hook onto this event if you know what you're doing.

Parameters:
    node: The currently visited node.
    alias: The alias instance.
    agent: The analysis agent currently running.
    **kwargs: For forward-compatibility.
r&   F)r$   aliasr%   Nr9   )rN   r#   )rP   r$   r   r%   re   s        r6   on_alias_instanceExtension.on_alias_instance  s/    * 4)511MMHtHH 2r8   c                   g)aS  Run on aliases once the object tree has been fully constructed.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    alias: The alias instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
Nr9   )rP   r   ro   re   s       r6   r#   Extension.on_alias  rh   r8   c               P    [        U S5      (       a  U R                  " SXS.UD6  gg)aK  Run when a package has been completely loaded.

Note:
    This method runs once the object tree has been fully constructed:
    data is therefore complete and you can safely hook onto this event.

Parameters:
    pkg: The package (Module) instance.
    loader: The loader currently in use.
    **kwargs: For forward-compatibility.
r    )pkgro   Nr9   )hasattrr    )rP   r   ro   re   s       r6   
on_packageExtension.on_package  s-     4,--""DsDVD .r8   r9   N)r$   zast.ASTr;   None)r$   r   r;   r   )r$   ast.AST | ObjectNoder%   Visitor | Inspectorre   r
   r;   r   )
r$   r   rk   r   r%   r   re   r
   r;   r   )rk   r   ro   r   re   r
   r;   r   )
r$   r   rz   r   r%   r   re   r
   r;   r   )rz   r   ro   r   re   r
   r;   r   )
r$   r   r1   r   r%   r   re   r
   r;   r   )r1   r   ro   r   re   r
   r;   r   )
r$   r   r   r   r%   r   re   r
   r;   r   )r   r   ro   r   re   r
   r;   r   )
r$   r   r   r   r%   r   re   r
   r;   r   )r   r   ro   r   re   r
   r;   r   )
r$   r   r   r   r%   r   re   r
   r;   r   )r   r   ro   r   re   r
   r;   r   )
r$   r   r   r   r%   r   re   r
   r;   r   )r   r   ro   r   re   r
   r;   r   )r   r   ro   r   re   r
   r;   r   )"r<   r=   r>   r?   r@   rQ   rV   r,   ra   rf   rl   rp   rs   rv   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r   rA   r9   r8   r6   rD   rD   @   s\   +GD$ # 	
 #  
, # 	
 #  
, # 	
 #  
, # 	
 #  
, # 	
 #  
, # 	
 #  
, # 	
 #  
, # 	
 #  
,I #I 	I
 #I I 
I0Er8   rD   )	metaclassc                  @    \ rS rSrSrS	S jrS	S jrS
S jrSS jrSr	g)
Extensionsi  zLThis class helps iterating on extensions that should run at different times.c                0    / U l         U R                  " U6   g)zZInitialize the extensions container.

Parameters:
    *extensions: The extensions to add.
N)_extensionsadd)rP   
extensionss     r6   __init__Extensions.__init__  s     -/*r8   c                L    U H  nU R                   R                  U5        M      g)zWAdd extensions to this container.

Parameters:
    *extensions: The extensions to add.
N)r   append)rP   r   	extensions      r6   r   Extensions.add  s"     $I##I. $r8   c                    g)z!No-op method for extension hooks.Nr9   )rP   re   s     r6   _noopExtensions._noop  rh   r8   c                   U R                    Hb  nUS:X  a=  [        USS5      (       a+  [        [        5         [        X15      " S0 UD6  SSS5        MF  [        X1U R                  5      " S0 UD6  Md     g! , (       d  f       Mv  = f)zCall the extension hook for the given event.

Parameters:
    event: The triggered event.
    **kwargs: Arguments passed to the hook.
r#   r&   FNr9   )r   rN   r   	TypeErrorr   )rP   eventre   r   s       r6   callExtensions.call  sl     ))I
"wy:JE'R'Ri(I-77 )( 	$**5?? * )(s   A44
B	)r   N)r   rD   r;   r   )re   r
   r;   r   )r   r:   re   r
   r;   r   )
r<   r=   r>   r?   r@   r   r   r   r   rA   r9   r8   r6   r   r     s    V/0@r8   r   dataclassesunpack_typeddictzset[str]builtin_extensionsc                   [         R                  R                  U 5      R                  SS5      S   n[	        X5      nU(       d  [        SU  S35      e[        U5      nU[        R                  U'   UR                  R                  U5        U$ )N.r'   r   z#Could not import module from path '')ospathbasenamersplitr   r   r   sysmodulesro   exec_module)r   module_namespecmodules       r6   _load_extension_pathr     sz    ''""4(//Q7:K";5D%(KD6QR&STTd#F%CKKKKF#Mr8   c                   Sn[        U [        5      (       a  U $ [        U 5      (       a  [        U [        5      (       a  U " 5       $ [        U [        5      (       a0  [        [        U R                  5       5      5      u  p#[        U5      nO[        U 5      n0 nUR                  S5      nUS:  d   U(       a.  S[        U5      R                  ;  a  UR                  SS5      u  p%OSnU[        ;   a  SU 3nO0[        R                  R!                  U5      (       a   [#        U5      nU(       d   [)        U5      n[        U5      (       a  [        U[        5      (       a  U" S0 UD6$ U(       a   [-        X5      " S0 UD6$ [1        U5      R3                  5        Vs/ s H9  n[        U5      (       d  M  [        U[        5      (       d  M,  U[        Ld  M7  UPM;     nnU V	s/ s H
  o" S0 UD6PM     sn	$ ! [$         a  n['        SU S35      UeSnAff = f! [*         a  n['        SU S35      UeSnAf[$         a  n['        SU SU 35      UeSnAff = f! [.         a  n['        SU S	U S
35      UeSnAff = fs  snf s  sn	f )a  Load a configured extension.

Parameters:
    extension: An extension, with potential configuration options.

Raises:
    ExtensionNotLoadedError: When the extension cannot be loaded,
        either because the module is not found, or because it does not expose
        the Extension attribute. ImportError will bubble up so users can see
        the traceback.

Returns:
    An extension instance.
N:r'   zgriffe._internal.extensions.zExtension module 'z' could not be foundz!Error while importing extension 'z': z
' has no 'z' attributer9   )
isinstancerD   r   
issubclassdictnextiteritemsr:   countr   driver   r   r   r   existsr   ImportErrorr   r   ModuleNotFoundErrorrN   AttributeErrorvarsvalues)
r   
ext_objectimport_pathoptionscolonsextension_nameerrorrk   r   exts
             r6   _load_extensionr     s   " J )Y'' yjI>>{ )T""#D):$;< +& )n s#FzfD,=,C,C!C&1&8&8a&@#^ ((4[MB		$	$	m-k:J 	r'4J zz*i@@$G$$ 	:6AAA J'..00GCLZPSU^E_dgoxdx0   '11jsCN'Nj11A  	m),>{mK_*`agll	m # 	m),>{mK_*`agll 	r),Mk]Z]^c]d*eflqq	r  	)$[MN;K;W	 2sr   G4 .H .I I<2I<	I<I< J4
H>HH
I H00I=II
I9!I44I9c                 4   [        5       nU  HE  n[        U5      n[        U[        5      (       a  UR                  " U6   M4  UR	                  U5        MG     SSKJn  UR                   H  n[        U5      UL d  M    U$    UR                  " [        S5      6   U$ )zLoad configured extensions.

Parameters:
    exts: Extensions with potential configuration options.

Returns:
    An extensions container.
r   )DataclassesExtensionr   )	r   r   r   listr   'griffe._internal.extensions.dataclassesr   r   type)extsr   r   r   r   s        r6   load_extensionsr   v  s     J	i(c4  NNC NN3  M%%9,,  & 	67r8   )r   r:   r;   r   )r   z2str | dict[str, Any] | Extension | type[Extension]r;   zExtension | list[Extension])r   LoadableExtensionTyper;   r   )8
__future__r   r,   r   r   r)   
contextlibr   importlib.utilr   r   r   pathlibr   typingr	   r
   r   !griffe._internal.agents.nodes.astr   r   griffe._internal.exceptionsr   griffe._internal.importerr   asttypesr   !griffe._internal.agents.inspectorr   %griffe._internal.agents.nodes.runtimer   griffe._internal.agents.visitorr   griffe._internal.loaderr   griffe._internal.modelsr   r   r   r   r   r   r   r   r   rD   r:   r   r  r   r   __annotations__r   r   r   r9   r8   r6   <module>r     s    #  	 
   D   , , D ? 4 ;@74ddd8$ 8@ZE- ZEz c4S>9d9oMN  <%@ %@R   H  /X2AX2 X2vr8   