
    JiD                       d dl mZ d dl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mZmZ d dlmZ erd dlmZ d d	lmZmZmZmZmZmZmZ  ed
      ZddZ G d d      Z G d d      Z G d d      Z G d d      Z  G d deeee       Z!y)    )annotationsN)suppress)TYPE_CHECKINGAnyTypeVar)Kind)AliasResolutionErrorBuiltinModuleErrorCyclicAliasError)merge_stubs)Sequence)Alias	AttributeClassFunctionModuleObject	TypeAlias_ObjTypec                    t        | t              r| st        d      | j                  d      }nt	        |       }|st        d      |S )NzEmpty strings are not supported.zEmpty tuples are not supported)
isinstancestr
ValueErrorsplitlist)keypartss     i/var/www/html/BankruptcyAI-uat/bankruptcy-ai/venv/lib/python3.12/site-packages/griffe/_internal/mixins.py
_get_partsr       sE    #s>??		#S	9::L    c                       e Zd ZdZddZddZy)GetMembersMixinz3Mixin class to share methods for accessing members.c                    t        |      }t        |      dk(  r| j                  |d      S | j                  |d      |dd    S )a  Get a member with its name or path.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        Members will be looked up in both declared members and inherited ones,
        triggering computation of the latter.

        Parameters:
            key: The name or path of the member.

        Examples:
            >>> foo = griffe_object["foo"]
            >>> bar = griffe_object["path.to.bar"]
            >>> qux = griffe_object[("path", "to", "qux")]
           r   N)r    lenall_membersselfr   r   s      r   __getitem__zGetMembersMixin.__getitem__%   sM    " 3u:?##E!H--a)%)44r!   c                    t        |      }t        |      dk(  r| j                  |d      S | j                  |d      j                  |dd       S )a  Get a member with its name or path.

        This method is part of the producer API:
        you can use it safely while building Griffe trees
        (for example in Griffe extensions).

        Members will be looked up in declared members only, not inherited ones.

        Parameters:
            key: The name or path of the member.

        Examples:
            >>> foo = griffe_object["foo"]
            >>> bar = griffe_object["path.to.bar"]
            >>> bar = griffe_object[("path", "to", "bar")]
        r%   r   N)r    r&   members
get_memberr(   s      r   r-   zGetMembersMixin.get_member;   sO    " 3u:?<<a))||E!H%00qr;;r!   N)r   str | Sequence[str]returnr   )__name__
__module____qualname____doc__r*   r-    r!   r   r#   r#   "   s    =5,<r!   r#   c                       e Zd ZdZddZddZy)DelMembersMixinz2Mixin class to share methods for deleting members.c                    t        |      }t        |      dk(  r|d   }	 | j                  |= y| j
                  |d      |dd = y# t        $ r | j                  |= Y yw xY w)a  Delete a member with its name or path.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        Members will be looked up in both declared members and inherited ones,
        triggering computation of the latter.

        Parameters:
            key: The name or path of the member.

        Examples:
            >>> del griffe_object["foo"]
            >>> del griffe_object["path.to.bar"]
            >>> del griffe_object[("path", "to", "qux")]
        r%   r   N)r    r&   r,   KeyErrorinherited_membersr'   r)   r   r   names       r   __delitem__zDelMembersMixin.__delitem__W   sp    " 3u:?8D1LL&   q*595  1**401s   A AAc                    t        |      }t        |      dk(  r|d   }| j                  |= y| j                  |d      j                  |dd        y)a  Delete a member with its name or path.

        This method is part of the producer API:
        you can use it safely while building Griffe trees
        (for example in Griffe extensions).

        Members will be looked up in declared members only, not inherited ones.

        Parameters:
            key: The name or path of the member.

        Examples:
            >>> griffe_object.del_member("foo")
            >>> griffe_object.del_member("path.to.bar")
            >>> griffe_object.del_member(("path", "to", "qux"))
        r%   r   N)r    r&   r,   
del_memberr:   s       r   r>   zDelMembersMixin.del_memberr   sN    " 3u:?8DT"LLq"--eABi8r!   N)r   r.   r/   None)r0   r1   r2   r3   r<   r>   r4   r!   r   r6   r6   T   s    <669r!   r6   c                       e Zd ZdZddZddZy)SetMembersMixinz1Mixin class to share methods for setting members.c                    t        |      }t        |      dk(  r0|d   }|| j                  |<   | j                  r| |_        y| |_        y|| j                  |d      |dd <   y)a  Set a member with its name or path.

        This method is part of the consumer API:
        do not use when producing Griffe trees!

        Parameters:
            key: The name or path of the member.
            value: The member.

        Examples:
            >>> griffe_object["foo"] = foo
            >>> griffe_object["path.to.bar"] = bar
            >>> griffe_object[("path", "to", "qux")] = qux
        r%   r   N)r    r&   r,   is_collection_modules_collectionparent)r)   r   valuer   r;   s        r   __setitem__zSetMembersMixin.__setitem__   sd     3u:?8D!&DLL!!,0)#05DLLq"59-r!   c                   t        |      }t        |      dk(  r&|d   }|| j                  v r| j                  |   }|j                  s|j                  r|j
                  sw|j                  skt        t        t        t              5  |j                  r=|j                  |j                  k7  r$t        t              5  t        ||      }ddd       ddd       |j                  j                         D ]!  }t        t              5  ||_        ddd       # || j                  |<   | j"                  r| |_        y| |_        y| j                  |d      j)                  |dd |       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)a  Set a member with its name or path.

        This method is part of the producer API:
        you can use it safely while building Griffe trees
        (for example in Griffe extensions).

        Parameters:
            key: The name or path of the member.
            value: The member.

        Examples:
            >>> griffe_object.set_member("foo", foo)
            >>> griffe_object.set_member("path.to.bar", bar)
            >>> griffe_object.set_member(("path", "to", "qux"), qux)
        r%   r   N)r    r&   r,   is_alias	is_moduleis_namespace_packageis_namespace_subpackager   r	   r   r
   filepathr   r   aliasesvaluestargetrC   rD   rE   
set_member)r)   r   rF   r   r;   memberaliass          r   rQ   zSetMembersMixin.set_member   s^     3u:?8Dt||#d+ ''1L1LPVPnPn &&:<LN`a G$5>>V__3T%-j%9 !G,7,FE!GG "(!6!6!8 1%&67 1+0EL1 11 "'DLL!!,0)#LLq"--eABi?!G !GG G
1 1s0   5E3;E'E3E?'E0	,E33E<?F	N)r   r.   rF   zObject | Aliasr/   r?   )r0   r1   r2   r3   rG   rQ   r4   r!   r   rA   rA      s    ;64)@r!   rA   c                  0    e Zd ZdZddddZedd       Zy)	SerializationMixinz8Mixin class to share methods for de/serializing objects.F)fullc               @    ddl m} t        j                  | f||d|S )a  Return this object's data as a JSON string.

        Parameters:
            full: Whether to return full info, or just base info.
            **kwargs: Additional serialization options passed to encoder.

        Returns:
            A JSON string.
        r   )JSONEncoder)clsrV   )griffe._internal.encodersrX   jsondumps)r)   rV   kwargsrX   s       r   as_jsonzSerializationMixin.as_json   s"     	:zz$EKdEfEEr!   c                    ddl m} |j                  d|       t        j                  |fi |}t        ||       st        d|        |S )a  Create an instance of this class from a JSON string.

        Parameters:
            json_string: JSON to decode into Object.
            **kwargs: Additional options passed to decoder.

        Returns:
            An Object instance.

        Raises:
            TypeError: When the json_string does not represent and object
                of the class from which this classmethod has been called.
        r   )json_decoderobject_hookz$provided JSON object is not of type )rZ   r`   
setdefaultr[   loadsr   	TypeError)rY   json_stringr]   r`   objs        r   	from_jsonzSerializationMixin.from_json   sL     	;-6jj//#s#B3%HII
r!   N)rV   boolr]   r   r/   r   )rY   ztype[_ObjType]re   r   r]   r   r/   r   )r0   r1   r2   r3   r^   classmethodrg   r4   r!   r   rU   rU      s"    B&+ F  r!   rU   c                     e Zd Z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y)ObjectAliasMixinzPMixin class to share methods that appear both in objects and aliases, unchanged.c                f    | j                   ri | j                  | j                  S | j                  S )zAll members (declared and inherited).

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )is_classr9   r,   r)   s    r   r'   zObjectAliasMixin.all_members   s/     ===d,,===||r!   c                    | j                   j                         D ci c]%  \  }}|j                  t        j                  u s#||' c}}S c c}}w )z~The module members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r'   itemskindr   MODULEr)   r;   rR   s      r   moduleszObjectAliasMixin.modules  sA     261A1A1G1G1IhvV[[\`\g\gMgfhhh   $AAc                    | j                   j                         D ci c]%  \  }}|j                  t        j                  u s#||' c}}S c c}}w )z}The class members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r'   rp   rq   r   CLASSrs   s      r   classeszObjectAliasMixin.classes  sA     261A1A1G1G1IgvV[[\`\f\fMffgggru   c                    | j                   j                         D ci c]%  \  }}|j                  t        j                  u s#||' c}}S c c}}w )zThe function members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r'   rp   rq   r   FUNCTIONrs   s      r   	functionszObjectAliasMixin.functions  sA     261A1A1G1G1IjvV[[\`\i\iMifjjjru   c                    | j                   j                         D ci c]%  \  }}|j                  t        j                  u s#||' c}}S c c}}w )zThe attribute members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r'   rp   rq   r   	ATTRIBUTErs   s      r   
attributeszObjectAliasMixin.attributes&  sA     261A1A1G1G1IkvV[[\`\j\jMjfkkkru   c                    | j                   j                         D ci c]%  \  }}|j                  t        j                  u s#||' c}}S c c}}w )zThe type alias members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        )r'   rp   rq   r   
TYPE_ALIASrs   s      r   type_aliaseszObjectAliasMixin.type_aliases/  sA     261A1A1G1G1IlvV[[\`\k\kMkflllru   c                V    | j                   j                  d      xr | j                   S )zGWhether this object/alias is private (starts with `_`) but not special._)r;   
startswith
is_specialrn   s    r   
is_privatezObjectAliasMixin.is_private8  s%     yy##C(@-@@r!   c                r    | j                   j                  d      xr | j                   j                  d      S )z[Whether this object/alias is special ("dunder" attribute/method, starts and end with `__`).__)r;   r   endswithrn   s    r   r   zObjectAliasMixin.is_special=  s-     yy##D)Fdii.@.@.FFr!   c                    t        | j                        xrQ | j                  j                  xr9 | j                  j	                  d      xr | j                  j                  d       S )zTWhether this object/alias is class-private (starts with `__` and is a class member).r   )rh   rE   rm   r;   r   r   rn   s    r   is_class_privatez!ObjectAliasMixin.is_class_privateB  sT     v$++"6"6v499;O;OPT;Uv^b^g^g^p^pqu^vZv	
r!   c                t    t        | j                        xr" | j                  | j                  j                  v S )z;Whether this object/alias was imported from another module.)rh   rE   r;   importsrn   s    r   is_importedzObjectAliasMixin.is_importedI  s+     DKK ETYY$++2E2E%EEr!   c                    t        | j                        xr[ | j                  j                  xrC t        | j                  j                  xr" | j                  | j                  j                  v       S )z<Whether this object/alias is exported (listed in `__all__`).)rh   rE   rJ   exportsr;   rn   s    r   is_exportedzObjectAliasMixin.is_exportedN  sX      O%%OT[[((MTYY$++:M:M-MN	
r!   c                l   | j                   r+t        | j                        r| j                  j                  sy| j                  j                  "| j
                  | j                  j                  v S | j
                  j                  d      ry| j                  xs | j                   xs | j                  S )a  Whether this object/alias is exposed to wildcard imports.

        To be exposed to wildcard imports, an object/alias must:

        - be available at runtime
        - have a module as parent
        - be listed in `__all__` if `__all__` is defined
        - or not be private (having a name starting with an underscore)

        Special case for Griffe trees: a submodule is only exposed if its parent imports it.

        Returns:
            True or False.
        Fr   )	runtimerh   rE   rJ   r   r;   r   rI   r   rn   s    r   is_wildcard_exposedz$ObjectAliasMixin.is_wildcard_exposedW  s    " ||D$5$++:O:O ;;*99 3 333 99$ }}FDNN 2Fd6F6FFr!   c                   | j                   | j                   S | j                  s(| j                  r| j                  j	                  d      sy| j
                  rW| j
                  j                  rAt        | j
                  j                        r"| j                  | j
                  j                  v S | j                  ry| j                  ryy)a  Whether this object is considered public.

        In modules, developers can mark objects as public thanks to the `__all__` variable.
        In classes however, there is no convention or standard to do so.

        Therefore, to decide whether an object is public, we follow this algorithm:

        - If the object's `public` attribute is set (boolean), return its value.
        - If the object is listed in its parent's (a module) `__all__` attribute, it is public.
        - If the parent (module) defines `__all__` and the object is not listed in, it is private.
        - If the object has a private name, it is private.
        - If the object was imported from another module, it is private.
        - Otherwise, the object is public.
        r   TF)
publicrI   rJ   r;   r   rE   rh   r   r   r   rn   s    r   	is_publiczObjectAliasMixin.is_publicw  s    " ;;";; }}		8L8LS8Q ;;4;;00T$++:M:M5N99 3 333
 ??
  r!   c                ,    t        | j                        S )z"Whether this object is deprecated.)rh   
deprecatedrn   s    r   is_deprecatedzObjectAliasMixin.is_deprecated  s     DOO$$r!   c                ,    t        | j                        S )zWhether this object is generic.)rh   type_parametersrn   s    r   
is_genericzObjectAliasMixin.is_generic  s     D(())r!   N)r/   zdict[str, Object | Alias])r/   zdict[str, Module])r/   zdict[str, Class])r/   zdict[str, Function])r/   zdict[str, Attribute])r/   zdict[str, TypeAlias])r/   rh   )r0   r1   r2   r3   propertyr'   rt   rx   r{   r~   r   r   r   r   r   r   r   r   r   r   r4   r!   r   rk   rk      sB   Z  i i h h k k l l m m A A G G 
 
 F F 
 
 G G> * *X % %
 * *r!   rk   )r   r.   r/   zSequence[str])"
__future__r   r[   
contextlibr   typingr   r   r   griffe._internal.enumerationsr   griffe._internal.exceptionsr	   r
   r   griffe._internal.mergerr   collections.abcr   griffe._internal.modelsr   r   r   r   r   r   r   r   r    r#   r6   rA   rU   rk   r4   r!   r   <module>r      s    #   . . . b b /(ddd:	-< -<d49 49nF@ F@R& &Rp*J\ p*r!   