
    Ji1                    B   U d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	 d dlm
Z
mZmZ d dlmZ d dlmZ e
r
d dlZd dlmZ d	ed
<   	 d dlZeefZej.                  D  ch c]  } | j1                  d       c} Zh dZddZ G d d      Zy# e$ r efZY Fw xY wc c} w )    )annotationsN)cached_property)GetSetDescriptorType
ModuleType)TYPE_CHECKINGAnyClassVar)
ObjectKind)logger)Sequenceztuple[types.ModuleType, ...]_TYPING_MODULES_>   znumpy.core._multiarray_umathznumpy.core.multiarrayosntr   posixc                   | j                  d      D cg c]  }|j                  d       c}|j                  d      D cg c]  }|j                  d       c}k(  S c c}w c c}w )N.r   )splitlstrip)abcpns      w/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/griffe/_internal/agents/nodes/runtime.py_same_componentsr   $   sN    '(wws|4CJJsO4TUT[T[\_T`8aSC8aaa48as   AA#c                     e Zd ZU dZh dZded<   	 dd dZd!dZed!d       Z	ed"d	       Z
ed#d
       Zed$d       Zed%d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed&d       Zed'd       Zd(dZed#d       Z y))
ObjectNodea)  Helper class to represent an object tree.

    It's not really a tree but more a backward-linked list:
    each node has a reference to its parent, but not to its child (for simplicity purposes and to avoid bugs).

    Each node stores an object, its name, and a reference to its parent node.
    >   __spec__
__loader____builtins__zClassVar[set[str]]exclude_specialsNc                
   	 t        j                  |      }t        |t              rd}|j                  }nd}|| _        	 || _	        	 || _
        	 || _        y# t        $ r!}t        j                  d||       Y d}~fd}~ww xY w)zInitialize the object.

        Parameters:
            obj: A Python object.
            name: The object's name.
            parent: The object's parent node.
        zCould not unwrap %s: %rNTF)inspectunwrap	Exceptionr   debug
isinstancer   funcobjnameparentis_cached_property)selfr+   r,   r-   errorr.   s         r   __init__zObjectNode.__init__4   s    	A..%C c?+!%((C!&'	')/(:>+  	A
 LL2D%@@	As   A 	B!A==Bc                "    d| j                   dS )NzObjectNode(name=))r,   r/   s    r   __repr__zObjectNode.__repr__V   s    !$))a00    c                |    | j                   | j                  S | j                   j                   d| j                   S )zThe object's (Python) path.r   )r-   r,   pathr4   s    r   r8   zObjectNode.pathY   s8     ;;99++""#1TYYK00r6   c                    | j                   r| S | j                  | j                  j                  S t        d| j                   d      )z0The object's module, fetched from the node tree.zObject node z does not have a parent module)	is_moduler-   module
ValueErrorr8   r4   s    r   r;   zObjectNode.module`   sC     >>K;;";;%%%<		{2PQRRr6   c                   	 | j                   j                  }t        |t              r8t	        j
                  d| j                         t        |dt        |dd            S t        |t              r|S t	        j
                  d| j                  t        t        |      dt        t        |                         y# t        $ r 	 t        j                  | j                         xs | j                  j                   }n# t        $ r Y Y yw xY w	 |j                  j                   cY S # t        $ r t        |dd      cY cY S w xY ww xY w)zThe object's module path.zObject %s has its `__module__` attribute set to a module object: it must be a string instead (the module fully qualified name). Please report to the maintainers of this library.__qualname____name__NzObject %s has its `__module__` attribute set to a %s object: it must be a string instead (the module fully qualified name). Please report to the maintainers of this library.)r+   
__module__r)   r   r   r(   r8   getattrstrtypeAttributeErrorr%   	getmoduler;   r<   r    r,   )r/   r;   s     r   module_pathzObjectNode.module_pathi   s   	XX((F &*-H II	 v~wvzSW7XYY&#&LLD 		Vj#d6l2CD ;  	9 **4884G 9+++! 9vz4889	9sS   B: :	E7C<;E<	D	ED		ED%"E%E ;E?E  Ec                2   | j                   rt        j                  S | j                  rt        j                  S | j
                  rt        j                  S | j                  rt        j                  S | j                  rt        j                  S | j                  rt        j                  S | j                  rt        j                  S | j                  rt        j                   S | j"                  rt        j$                  S | j&                  rt        j(                  S | j*                  rt        j,                  S | j.                  rt        j0                  S | j2                  rt        j4                  S | j6                  rt        j8                  S t        j:                  S )zThe kind of this node.)r:   r
   MODULEis_classCLASSis_staticmethodSTATICMETHODis_classmethodCLASSMETHODr.   CACHED_PROPERTY	is_methodMETHODis_builtin_methodBUILTIN_METHODis_coroutine	COROUTINEis_builtin_functionBUILTIN_FUNCTIONis_method_descriptorMETHOD_DESCRIPTORis_functionFUNCTIONis_getset_descriptorGETSET_DESCRIPTORis_propertyPROPERTYis_type_alias
TYPE_ALIAS	ATTRIBUTEr4   s    r   kindzObjectNode.kind   s0    >>$$$==###***)))""--->>$$$!!,,,'''##...$$///&&&$$///&&&(((###r6   c                    g }t        j                  | j                        D ]5  \  }}| j                  ||      s|j	                  t        |||              7 |S )zThe children of this node.)r-   )r%   
getmembersr+   _pick_memberappendr   )r/   childrenr,   members       r   rh   zObjectNode.children   sY     #..txx8 	GLD&  v.
64 EF	G r6   c                @    t        j                  | j                        S )z'Whether this node's object is a module.)r%   ismoduler+   r4   s    r   r:   zObjectNode.is_module   s     ))r6   c                @    t        j                  | j                        S )z&Whether this node's object is a class.)r%   isclassr+   r4   s    r   rI   zObjectNode.is_class   s     txx((r6   c                    t        j                  | j                        xs$ t        | j                        xr | j                   S )z)Whether this node's object is a function.)r%   
isfunctionr+   callablerI   r4   s    r   rZ   zObjectNode.is_function   s3     !!$((+Y0B0X4==GXYr6   c                V    t        | j                  t        d t        D                    S )z+Whether this node's object is a type alias.c              3  N   K   | ]  }t        |d       s|j                    yw)TypeAliasTypeN)hasattrrs   ).0r;   s     r   	<genexpr>z+ObjectNode.is_type_alias.<locals>.<genexpr>   s!     i6PVXgHh&&&is   %%)r)   r+   tupler   r4   s    r   r`   zObjectNode.is_type_alias   s&     HHi_ii
 	
r6   c                @    t        j                  | j                        S )z1Whether this node's object is a builtin function.)r%   	isbuiltinr+   r4   s    r   rV   zObjectNode.is_builtin_function   s       **r6   c                @    t        j                  | j                        S )z*Whether this node's object is a coroutine.)r%   iscoroutinefunctionr+   r4   s    r   rT   zObjectNode.is_coroutine   s     **48844r6   c                6    t        | j                  t              S )z3Whether this node's object is a get/set descriptor.)r)   r+   r   r4   s    r   r\   zObjectNode.is_getset_descriptor   s     $(($899r6   c                R    t        | j                  t              xs | j                  S )z)Whether this node's object is a property.)r)   r+   propertyr.   r4   s    r   r^   zObjectNode.is_property   s      $((H-H1H1HHr6   c                \    t        | j                  xr | j                  j                        S )z4Whether the object of this node's parent is a class.)boolr-   rI   r4   s    r   parent_is_classzObjectNode.parent_is_class   s"     DKK8DKK$8$899r6   c                b    t        d       }| j                  xr t        | j                  |      S )z'Whether this node's object is a method.c                      y N r   r6   r   <lambda>z&ObjectNode.is_method.<locals>.<lambda>   s    r6   )rC   r   r)   r+   )r/   function_types     r   rP   zObjectNode.is_method   s*     \*##K
488](KKr6   c                @    t        j                  | j                        S )zWhether this node's object is a method descriptor.

        Built-in methods (e.g. those implemented in C/Rust) are often
        method descriptors, rather than normal methods.
        )r%   ismethoddescriptorr+   r4   s    r   rX   zObjectNode.is_method_descriptor   s     ))$((33r6   c                6    | j                   xr | j                  S )z/Whether this node's object is a builtin method.)rV   r   r4   s    r   rR   zObjectNode.is_builtin_method   s     ''@D,@,@@r6   c                    | j                   y	 | j                   j                  j                  j                  | j                  d      }| j                  xr t        |t              S # t
        $ r Y yw xY w)z-Whether this node's object is a staticmethod.NF)	r-   r+   __dict__getr,   rD   r   r)   staticmethodr/   self_from_parents     r   rK   zObjectNode.is_staticmethod   sj     ;;	#{{77;;DIItL ##R
3C\(RR  		   :A' '	A32A3c                    | j                   y	 | j                   j                  j                  j                  | j                  d      }| j                  xr t        |t              S # t
        $ r Y yw xY w)z,Whether this node's object is a classmethod.NF)	r-   r+   r   r   r,   rD   r   r)   classmethodr   s     r   rM   zObjectNode.is_classmethod  sj     ;;	#{{77;;DIItL ##Q
3C[(QQ  		r   c                :    | j                   t        j                  u S )z+Whether this node's object is an attribute.)rc   r
   rb   r4   s    r   is_attributezObjectNode.is_attribute  s     yyJ0000r6   c                    | j                   t        | j                        hS t        | j                        h| j                   j                  z  S r   )r-   idr+   _idsr4   s    r   r   zObjectNode._ids  s;    ;;txxL>!488~ 0 000r6   c                    || j                   vxrD |t        uxr: |t        uxr0 t        |      | j                  vxr |t        | j                        v S r   )r#   rC   objectr   r   varsr+   )r/   r,   ri   s      r   rf   zObjectNode._pick_member  s]    --- 'd"'f$' 6
$))+' TXX&	
r6   c                   | j                   y| j                  ry| j                  }|sy| j                   j                  }|sy||ft        v ryt	        ||      ry|j                  d      t        v r|j                  d      }| j                  r|S t        | j                  d| j                  t        | j                  j                        dz   d       }| d| S )z?Alias target path of this node, if the node should be an alias.Nr   r>      r   )r-   r   rF   _cyclic_relationshipsr   r   _builtin_module_namesr:   rA   r+   r8   lenr;   )r/   child_module_pathparent_module_path
child_names       r   alias_target_pathzObjectNode.alias_target_path&  s     ;;  !,,  "[[44!  126KK .0AB ##C(,AA 1 8 8 = >>$$ TXX~tyyT[[EUEUAVYZAZA\7]^
#$Aj\22r6   r   )r+   r   r,   rB   r-   zObjectNode | NonereturnNone)r   rB   )r   r   )r   z
str | None)r   r
   )r   zSequence[ObjectNode])r   r   )r   zset[int])r,   rB   ri   r   r   r   )!r?   r@   r>   __doc__r#   __annotations__r1   r5   r~   r8   r;   rF   rc   r   rh   r:   rI   rZ   r`   rV   rT   r\   r^   r   rP   rX   rR   rK   rM   r   r   rf   r   r   r6   r   r   r   (   s    ,V(UL ?D1 1 1 S S ! !F $ $@   * * ) ) Z Z
 
 
 + + 5 5 : : I I : : L L
 4 4 A A S S R R 1 1 1 1

 .3 .3r6   r   )r   rB   r   rB   r   r   )
__future__r   r%   systyping	functoolsr   typesr   r   r   r   r	   griffe._internal.enumerationsr
   griffe._internal.loggerr   collections.abcr   r   typing_extensionsr   ImportErrorbuiltin_module_namesr   r   r   r   r   )r   s   0r   <module>r      s    #  
  % 2 / / 4 *(- -2 01O 140H0HI1#I  bm3 m3%   iO  Js   
B  BBB