
    -huG                    >   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  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_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     K/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/_griffe/mixins.py
_get_partsr"      sd    #s  	@>???		#S		 ;9:::L    c                  "    e Zd ZdZd	dZd	dZdS )
GetMembersMixinzMixin class to share methods for accessing members.

    Methods:
        get_member: Get a member with its name or path.
        __getitem__: Same as `get_member`, with the item syntax `[]`.
    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!   r/   zGetMembersMixin.get_member@   sV    " 3u::??<a))|E!H%00qrr;;;r#   N)r   r   r   r   )__name__
__module____qualname____doc__r,   r/    r#   r!   r%   r%   "   sF         5 5 5 5,< < < < < <r#   r%   c                  "    e Zd ZdZd	dZd	dZdS )
DelMembersMixinzMixin class to share methods for deleting members.

    Methods:
        del_member: Delete a member with its name or path.
        __delitem__: Same as `del_member`, with the item syntax `[]`.
    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__a   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_member|   sd    " 3u::??8DT"""Lq"--eABBi88888r#   N)r   r   r   r7   )r0   r1   r2   r3   r=   r?   r4   r#   r!   r6   r6   Y   sF         6 6 6 669 9 9 9 9 9r#   r6   c                  "    e Zd ZdZddZdd	Zd
S )SetMembersMixinzMixin class to share methods for setting members.

    Methods:
        set_member: Set a member with its name or path.
        __setitem__: Same as `set_member`, with the item syntax `[]`.
    r   r   valueObject | Aliasr   r7   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   rB   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targetrE   rF   rG   
set_member)r+   r   rB   r    r<   memberaliass          r!   rR   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   rB   rC   r   r7   )r0   r1   r2   r3   rH   rR   r4   r#   r!   rA   rA      sL         6 6 6 64)@ )@ )@ )@ )@ )@r#   rA   c                  8    e Zd ZdZdddd
Zedd            ZdS )SerializationMixinzMixin class to share methods for de/serializing objects.

    Methods:
        as_json: Return this object's data as a JSON string.
        from_json: Create an instance of this class from a JSON string.
    F)fullrW   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)clsrW   )_griffe.encodersr[   jsondumps)r+   rW   rY   r[   s       r!   as_jsonzSerializationMixin.as_json   s5     	100000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]   rd   
setdefaultr^   loadsr   	TypeError)r\   rb   rY   rd   objs        r!   	from_jsonzSerializationMixin.from_json   sr     	211111-666j////#s## 	JH3HHIII
r#   N)rW   rX   rY   r   r   r   )r\   ra   rb   r   rY   r   r   r   )r0   r1   r2   r3   r`   classmethodrj   r4   r#   r!   rV   rV      sg          ', F F F F F F    [  r#   rV   c                  J   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dS )ObjectAliasMixina  Mixin class to share methods that appear both in objects and aliases, unchanged.

    Attributes:
        all_members: All members (declared and inherited).
        modules: The module members.
        classes: The class members.
        functions: The function members.
        attributes: The attribute members.
        is_private: Whether this object/alias is private (starts with `_`) but not special.
        is_class_private: Whether this object/alias is class-private (starts with `__` and is a class member).
        is_special: Whether this object/alias is special ("dunder" attribute/method, starts and end with `__`).
        is_imported: Whether this object/alias was imported from another module.
        is_exported: Whether this object/alias is exported (listed in `__all__`).
        is_wildcard_exposed: Whether this object/alias is exposed to wildcard imports.
        is_public: Whether this object is considered public.
        is_deprecated: Whether this object is deprecated.
    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 r4   )kindr   MODULE.0r<   rS   s      r!   
<dictcomp>z,ObjectAliasMixin.modules.<locals>.<dictcomp>6  s.    hhhvV[\`\gMgMgfMgMgMgr#   r)   itemsrq   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 r4   )ru   r   CLASSrw   s      r!   ry   z,ObjectAliasMixin.classes.<locals>.<dictcomp>?  s.    gggvV[\`\fMfMffMfMfMfr#   rz   rq   s    r!   classeszObjectAliasMixin.classes8  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 r4   )ru   r   FUNCTIONrw   s      r!   ry   z.ObjectAliasMixin.functions.<locals>.<dictcomp>H  s.    jjjvV[\`\iMiMifMiMiMir#   rz   rq   s    r!   	functionszObjectAliasMixin.functionsA  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 r4   )ru   r   	ATTRIBUTErw   s      r!   ry   z/ObjectAliasMixin.attributes.<locals>.<dictcomp>Q  s.    kkkvV[\`\jMjMjfMjMjMjr#   rz   rq   s    r!   
attributeszObjectAliasMixin.attributesJ  s(     lk1A1G1G1I1Ikkkkr#   rX   c                F    | j                             d          o| j         S )zGWhether this object/alias is private (starts with `_`) but not special._)r<   
startswith
is_specialrq   s    r!   
is_privatezObjectAliasMixin.is_privateS  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   endswithrq   s    r!   r   zObjectAliasMixin.is_specialX  s/     y##D))Fdi.@.@.F.FFr#   c                    | 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   )rG   rp   r<   r   r   rq   s    r!   is_class_privatez!ObjectAliasMixin.is_class_private]  sF     {st{3s	8L8LT8R8Rs[_[d[m[mnr[s[sWssr#   c                6    | j         o| j        | j         j        v S )z;Whether this object/alias was imported from another module.)rG   r<   importsrq   s    r!   is_importedzObjectAliasMixin.is_importedb  s     {?tyDK,???r#   c                r    | j         j        o+t          | j         j        o| j        | j         j        v           S )z<Whether this object/alias is exported (listed in `__all__`).)rG   rK   rX   exportsr<   rq   s    r!   is_exportedzObjectAliasMixin.is_exportedg  s4     {$gdk.A.fdiSWS^SfFf)g)ggr#   c                    | 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   )runtimerG   rK   r   r<   r   rJ   r   rq   s    r!   is_wildcard_exposedz$ObjectAliasMixin.is_wildcard_exposedl  sy    " | 	4;#8 	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)
publicrJ   rK   r<   r   rG   rX   r   r   r   rq   s    r!   	is_publiczObjectAliasMixin.is_public  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.)rX   
deprecatedrq   s    r!   is_deprecatedzObjectAliasMixin.is_deprecated  s     DO$$$r#   N)r   rn   )r   rr   )r   r}   )r   r   )r   r   )r   rX   )r0   r1   r2   r3   propertyr)   r|   r   r   r   r   r   r   r   r   r   r   r   r4   r#   r!   rm   rm     s        $    X i i i Xi h h h Xh k k k Xk l l l Xl A A A XA G G G XG t t t Xt @ @ @ X@ h h h Xh G G G XG> * * * X*X % % % X% % %r#   rm   )r   r   r   r   )!
__future__r   r^   
contextlibr   typingr   r   r   _griffe.enumerationsr   _griffe.exceptionsr	   r
   r   _griffe.mergerr   collections.abcr   _griffe.modelsr   r   r   r   r   r   r   r"   r%   r6   rA   rV   rm   r4   r#   r!   <module>r      s   # " " " " "        . . . . . . . . . . % % % % % % Y Y Y Y Y Y Y Y Y Y & & & & & & Q((((((PPPPPPPPPPPPPPPP7:	 	 	 	2< 2< 2< 2< 2< 2< 2< 2<n99 99 99 99 99 99 99 99xK@ K@ K@ K@ K@ K@ K@ K@\+ + + + + + + +\l% l% l% l% l%J\ l% l% l% l% l%r#   