
    5'h*                        d dl mZ d dlZd dlZd dlmZ d dl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mZ ej$                  D  ch c]  } | j'                  d	       c} Zh d
ZddZ G d d      Zyc c} w )    )annotationsN)cached_property)GetSetDescriptorType)TYPE_CHECKINGAnyClassVar)
ObjectKind)logger)Sequence_>   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      c/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/_griffe/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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__)   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__K   s    !$))a00    c                |    | j                   | j                  S | j                   j                   d| j                   S )zThe object's (Python) path.r   )r+   r*   pathr2   s    r   r6   zObjectNode.pathN   s8     ;;99++""#1TYYK00r4   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
ValueErrorr6   r2   s    r   r9   zObjectNode.moduleU   sC     >>K;;";;%%%<		{2PQRRr4   c                J   	 | j                   j                  S # 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.N__name__)
r)   
__module__AttributeErrorr#   	getmoduler9   r:   r   r*   getattr)r-   r9   s     r   module_pathzObjectNode.module_path^   s    
	988&&& 	9 **4884G 9+++! 9vz4889	9sP    	B"7AB"	A'#B"&A''B"+B B"BB"BB"c                   | 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 t        j6                  S )zThe kind of this node.)r8   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	ATTRIBUTEr2   s    r   kindzObjectNode.kindm   s    >>$$$==###***)))""--->>$$$!!,,,'''##...$$///&&&$$///&&&###r4   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   ra   zObjectNode.children   sY     #..txx8 	GLD&  v.
64 EF	G r4   c                @    t        j                  | j                        S )z'Whether this node's object is a module.)r#   ismoduler)   r2   s    r   r8   zObjectNode.is_module   s     ))r4   c                @    t        j                  | j                        S )z&Whether this node's object is a class.)r#   isclassr)   r2   s    r   rD   zObjectNode.is_class   s     txx((r4   c                    t        j                  | j                        xs$ t        | j                        xr | j                   S )z)Whether this node's object is a function.)r#   
isfunctionr)   callablerD   r2   s    r   rU   zObjectNode.is_function   s3     !!$((+Y0B0X4==GXYr4   c                @    t        j                  | j                        S )z1Whether this node's object is a builtin function.)r#   	isbuiltinr)   r2   s    r   rQ   zObjectNode.is_builtin_function   s       **r4   c                @    t        j                  | j                        S )z*Whether this node's object is a coroutine.)r#   iscoroutinefunctionr)   r2   s    r   rO   zObjectNode.is_coroutine   s     **48844r4   c                6    t        | j                  t              S )z3Whether this node's object is a get/set descriptor.)r'   r)   r   r2   s    r   rW   zObjectNode.is_getset_descriptor   s     $(($899r4   c                R    t        | j                  t              xs | j                  S )z)Whether this node's object is a property.)r'   r)   propertyr,   r2   s    r   rY   zObjectNode.is_property   s      $((H-H1H1HHr4   c                \    t        | j                  xr | j                  j                        S )z4Whether the object of this node's parent is a class.)boolr+   rD   r2   s    r   parent_is_classzObjectNode.parent_is_class   s"     DKK8DKK$8$899r4   c                b    t        d       }| j                  xr t        | j                  |      S )z'Whether this node's object is a method.c                      y N rw   r4   r   <lambda>z&ObjectNode.is_method.<locals>.<lambda>   s    r4   )typers   r'   r)   )r-   function_types     r   rK   zObjectNode.is_method   s*     \*##K
488](KKr4   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)   r2   s    r   rS   zObjectNode.is_method_descriptor   s     ))$((33r4   c                6    | j                   xr | j                  S )z/Whether this node's object is a builtin method.)rQ   rs   r2   s    r   rM   zObjectNode.is_builtin_method   s     ''@D,@,@@r4   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*   r>   rs   r'   staticmethodr-   self_from_parents     r   rF   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*   r>   rs   r'   classmethodr   s     r   rH   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.)r\   r	   r[   r2   s    r   is_attributezObjectNode.is_attribute   s     yyJ0000r4   c                    | j                   t        | j                        hS t        | j                        h| j                   j                  z  S rv   )r+   idr)   _idsr2   s    r   r   zObjectNode._ids   s;    ;;txxL>!488~ 0 000r4   c                    || j                   vxrD |t        uxr: |t        uxr0 t        |      | j                  vxr |t        | j                        v S rv   )r!   ry   objectr   r   varsr)   )r-   r*   rb   s      r   r_   zObjectNode._pick_member   s]    --- 'd"'f$' 6
$))+' TXX&	
r4   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   __qualname__   r   )r+   r   rA   _cyclic_relationshipsr   r   _builtin_module_namesr8   r@   r)   r6   lenr9   )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2r4   rv   )r)   r   r*   strr+   zObjectNode | NonereturnNone)r   r   )r   r   )r   z
str | None)r   r	   )r   zSequence[ObjectNode])r   rr   )r   zset[int])r*   r   rb   r   r   rr   ) r<   r=   r   __doc__r!   __annotations__r/   r3   rp   r6   r9   rA   r\   r   ra   r8   rD   rU   rQ   rO   rW   rY   rs   rK   rS   rM   rF   rH   r   r   r_   r   rw   r4   r   r   r      s    ,V(UL ?D1 1 1 S S 9 9 $ $<   * * ) ) Z Z
 + + 5 5 : : I I : : L L
 4 4 A A S S R R 1 1 1 1

 .3 .3r4   r   )r   r   r   r   r   rr   )
__future__r   r#   sys	functoolsr   typesr   typingr   r   r   _griffe.enumerationsr	   _griffe.loggerr
   collections.abcr   builtin_module_namesr   r   r   r   r   )r   s   0r   <module>r      sg    #  
 % & / / + !(030H0HI1#I  bN3 N3 Js   A5