
    %jE                    B   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!dS )    )annotationsN)suppress)TYPE_CHECKINGAnyTypeVar)Kind)AliasResolutionErrorBuiltinModuleErrorCyclicAliasError)merge_stubs)Sequence)Alias	AttributeClassFunctionModuleObject	TypeAlias_ObjTypekeystr | Sequence[str]returnSequence[str]c                    t          | t                    r'| st          d          |                     d          }nt	          |           }|st          d          |S )NzEmpty strings are not supported.zEmpty tuples are not supported)
isinstancestr
ValueErrorsplitlist)r   partss     _/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/griffe/_internal/mixins.py
_get_partsr#      sd    #s  	@>???		#S		 ;9:::L    c                  "    e Zd ZdZd	dZd	dZdS )
GetMembersMixinz3Mixin class to share methods for accessing members.r   r   r   r   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__%   sO    " 3u::??#E!H--a)%)44r$   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 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"   r0   zGetMembersMixin.get_member;   sV    " 3u::??<a))|E!H%00qrr;;;r$   N)r   r   r   r   )__name__
__module____qualname____doc__r-   r0    r$   r"   r&   r&   "   sB        ==5 5 5 5,< < < < < <r$   r&   c                  "    e Zd ZdZd	dZd	dZdS )
DelMembersMixinz2Mixin class to share methods for deleting members.r   r   r   Nonec                    t          |          }t          |          dk    r,|d         }	 | j        |= dS # t          $ r | j        |= Y dS w xY w| j        |d                  |dd         = dS )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   s    " 3u::??8D1L&&& 1 1 1*400001  q*59555s   6 AAc                    t          |          }t          |          dk    r|d         }| j        |= dS | j        |d                                      |dd                    dS )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   sd    " 3u::??8DT"""Lq"--eABBi88888r$   N)r   r   r   r8   )r1   r2   r3   r4   r>   r@   r5   r$   r"   r7   r7   T   sB        <<6 6 6 669 9 9 9 9 9r$   r7   c                  "    e Zd ZdZddZdd	Zd
S )SetMembersMixinz1Mixin class to share methods for setting members.r   r   valueObject | Aliasr   r8   c                    t          |          }t          |          dk    r+|d         }|| j        |<   | j        r	| |_        dS | |_        dS || j        |d                  |dd         <   dS )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   rC   r!   r=   s        r"   __setitem__zSetMembersMixin.__setitem__   sz     3u::??8D!&DL! $,0)))#05DLq"59---r$   c                   t          |          }t          |          dk    r8|d         }|| j        v r| j        |         }|j        s|j        r|j        s|j        st          t          t          t                    5  |j        rL|j        |j        k    r<t          t                    5  t          ||          }ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |j                                        D ]5}t          t                    5  ||_        ddd           n# 1 swxY w Y   6|| j        |<   | j        r	| |_        dS | |_        dS | j        |d                                      |dd         |           dS )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targetrF   rG   rH   
set_member)r,   r   rC   r!   r=   memberaliass          r"   rS   zSetMembersMixin.set_member   sr     3u::??8Dt|##d+ 1 ' G1L GPVPn G &&:<LN`aa G G$ G5>V_3T3T%-j%9%9 !G !G,7,F,FE!G !G !G !G !G !G !G !G !G !G !G !G !G !G !GG G G G G G G G G G G G G G G "(!6!6!8!8 1 1%&677 1 1+0EL1 1 1 1 1 1 1 1 1 1 1 1 1 1 1!&DL! $,0)))#Lq"--eABBi?????sH   ?,C+C<CC	CC	CC#&C#D--D1	4D1	N)r   r   rC   rD   r   r8   )r1   r2   r3   r4   rI   rS   r5   r$   r"   rB   rB      sH        ;;6 6 6 64)@ )@ )@ )@ )@ )@r$   rB   c                  8    e Zd ZdZdddd
Zedd            ZdS )SerializationMixinz8Mixin class to share methods for de/serializing objects.F)fullrX   boolkwargsr   r   r   c               8    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)clsrX   )griffe._internal.encodersr\   jsondumps)r,   rX   rZ   r\   s       r"   as_jsonzSerializationMixin.as_json   s5     	:99999z$EKdEEfEEEr$   r]   type[_ObjType]json_stringr   c                    ddl m} |                    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 )r^   re   
setdefaultr_   loadsr   	TypeError)r]   rc   rZ   re   objs        r"   	from_jsonzSerializationMixin.from_json   sr     	;:::::-666j////#s## 	JH3HHIII
r$   N)rX   rY   rZ   r   r   r   )r]   rb   rc   r   rZ   r   r   r   )r1   r2   r3   r4   ra   classmethodrk   r5   r$   r"   rW   rW      sa        BB&+ F F F F F F    [  r$   rW   c                  z   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dS )!ObjectAliasMixinzPMixin class to share methods that appear both in objects and aliases, unchanged.r   dict[str, Object | Alias]c                >    | 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_classr;   r/   r,   s    r"   r*   zObjectAliasMixin.all_members   s+     = 	>=d,===|r$   dict[str, Module]c                H    d | j                                         D             S )z~The module members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        c                @    i | ]\  }}|j         t          j        u ||S r5   )kindr   MODULE.0r=   rT   s      r"   
<dictcomp>z,ObjectAliasMixin.modules.<locals>.<dictcomp>  s.    hhhvV[\`\gMgMgfMgMgMgr$   r*   itemsrr   s    r"   moduleszObjectAliasMixin.modules  s(     ih1A1G1G1I1Ihhhhr$   dict[str, Class]c                H    d | j                                         D             S )z}The class members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        c                @    i | ]\  }}|j         t          j        u ||S r5   )rv   r   CLASSrx   s      r"   rz   z,ObjectAliasMixin.classes.<locals>.<dictcomp>  s.    gggvV[\`\fMfMffMfMfMfr$   r{   rr   s    r"   classeszObjectAliasMixin.classes  s(     hg1A1G1G1I1Iggggr$   dict[str, Function]c                H    d | j                                         D             S )zThe function members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        c                @    i | ]\  }}|j         t          j        u ||S r5   )rv   r   FUNCTIONrx   s      r"   rz   z.ObjectAliasMixin.functions.<locals>.<dictcomp>$  s.    jjjvV[\`\iMiMifMiMiMir$   r{   rr   s    r"   	functionszObjectAliasMixin.functions  s(     kj1A1G1G1I1Ijjjjr$   dict[str, Attribute]c                H    d | j                                         D             S )zThe attribute members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        c                @    i | ]\  }}|j         t          j        u ||S r5   )rv   r   	ATTRIBUTErx   s      r"   rz   z/ObjectAliasMixin.attributes.<locals>.<dictcomp>-  s.    kkkvV[\`\jMjMjfMjMjMjr$   r{   rr   s    r"   
attributeszObjectAliasMixin.attributes&  s(     lk1A1G1G1I1Ikkkkr$   dict[str, TypeAlias]c                H    d | j                                         D             S )zThe type alias members.

        This method is part of the consumer API:
        do not use when producing Griffe trees!
        c                @    i | ]\  }}|j         t          j        u ||S r5   )rv   r   
TYPE_ALIASrx   s      r"   rz   z1ObjectAliasMixin.type_aliases.<locals>.<dictcomp>6  s.    lllvV[\`\kMkMkfMkMkMkr$   r{   rr   s    r"   type_aliaseszObjectAliasMixin.type_aliases/  s(     ml1A1G1G1I1Illllr$   rY   c                F    | j                             d          o| j         S )zGWhether this object/alias is private (starts with `_`) but not special._)r=   
startswith
is_specialrr   s    r"   
is_privatezObjectAliasMixin.is_private8  s$     y##C((@-@@r$   c                j    | j                             d          o| j                             d          S )z[Whether this object/alias is special ("dunder" attribute/method, starts and end with `__`).__)r=   r   endswithrr   s    r"   r   zObjectAliasMixin.is_special=  s/     y##D))Fdi.@.@.F.FFr$   c                    t          | j                  o@| j        j        o4| j                            d          o| j                            d           S )zTWhether this object/alias is class-private (starts with `__` and is a class member).r   )rY   rH   rq   r=   r   r   rr   s    r"   is_class_privatez!ObjectAliasMixin.is_class_privateB  sQ     v$+"6v49;O;OPT;U;Uv^b^g^p^pqu^v^vZv	
r$   c                P    t          | j                  o| j        | j        j        v S )z;Whether this object/alias was imported from another module.)rY   rH   r=   importsrr   s    r"   is_importedzObjectAliasMixin.is_importedI  s%     DK  ETY$+2E%EEr$   c                    t          | j                  o7| j        j        o+t          | j        j        o| j        | j        j        v           S )z<Whether this object/alias is exported (listed in `__all__`).)rY   rH   rL   exportsr=   rr   s    r"   is_exportedzObjectAliasMixin.is_exportedN  sK      O%OT[(MTY$+:M-MNN	
r$   c                    | j         r t          | j                  r| j        j        sdS | j        j        | j        | j        j        v S | j                            d          rdS | j        p| j         p| 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.
        FNr   )	runtimerY   rH   rL   r   r=   r   rK   r   rr   s    r"   is_wildcard_exposedz$ObjectAliasMixin.is_wildcard_exposedW  s    " | 	D$5$5 	$+:O 	5 ;*9 333 9$$ 	5 }FDN 2Fd6FFr$   c                   | j         | j         S | j        s#| j        r| j                            d          sdS | j        r8| j        j        r,t          | j        j                  r| j        | j        j        v S | j        rdS | j	        rdS dS )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.
        Nr   TF)
publicrK   rL   r=   r   rH   rY   r   r   r   rr   s    r"   	is_publiczObjectAliasMixin.is_publicw  s    " ;"; } 	 		8L8LS8Q8Q 	4 ; 	44;0 	4T$+:M5N5N 	49 333
 ? 	5
  	5 tr$   c                *    t          | j                  S )z"Whether this object is deprecated.)rY   
deprecatedrr   s    r"   is_deprecatedzObjectAliasMixin.is_deprecated  s     DO$$$r$   c                *    t          | j                  S )zWhether this object is generic.)rY   type_parametersrr   s    r"   
is_genericzObjectAliasMixin.is_generic  s     D()))r$   N)r   ro   )r   rs   )r   r~   )r   r   )r   r   )r   r   )r   rY   )r1   r2   r3   r4   propertyr*   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r5   r$   r"   rn   rn      s       ZZ   X i i i Xi h h h Xh k k k Xk l l l Xl m m m Xm A A A XA G G G XG 
 
 
 X
 F F F XF 
 
 
 X
 G G G XG> * * * X*X % % % X%
 * * * X* * *r$   rn   )r   r   r   r   )"
__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&   r7   rB   rW   rn   r5   r$   r"   <module>r      s   # " " " " "        . . . . . . . . . . . . . . . . b b b b b b b b b b / / / / / / e((((((dddddddddddddddddd7:	 	 	 	-< -< -< -< -< -< -< -<d49 49 49 49 49 49 49 49nF@ F@ F@ F@ F@ F@ F@ F@R& & & & & & & &Rp* p* p* p* p*J\ p* p* p* p* p*r$   