ó
    øÞ jX  ã                  óX  • % S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
JrJr  SSKJrJrJrJrJr  SSKJrJrJr  S	S
KJr  Sr\R4                  S:¼  a  S'S jrOS'S jr\\-  \-  \-  \
-  \R@                  -  r!S(S jr"SSS.       S)S jjr#\S   r$S\%S'    \&" \" \$5      5      r'S\%S'    " S S\5      r( " S S\)5      r* " S S\
5      r+\+RX                  r, \\+RX                     r-S\%S'     " S  S!\5      r.S"S#.       S*S$ jjr/        S+S% jr0SS#.     S,S& jjr1g)-zEHigh-level introspection utilities, used to inspect type annotations.é    )ÚannotationsN)Ú	Generator)ÚInitVar)ÚEnumÚIntEnumÚauto)ÚAnyÚLiteralÚ
NamedTupleÚ	TypeAliasÚcast)Úassert_neverÚget_argsÚ
get_originé   )Útyping_objects)ÚAnnotationSourceÚForbiddenQualifierÚInspectedAnnotationÚ	QualifierÚget_literal_valuesÚinspect_annotationÚis_union_origin)é   é   c               ó.   • [         R                  " U 5      $ ©a8  Return whether the provided origin is the union form.

```pycon
>>> is_union_origin(typing.Union)
True
>>> is_union_origin(get_origin(int | str))
True
>>> is_union_origin(types.UnionType)
True
```

!!! note
    Since Python 3.14, both `Union[<t1>, <t2>, ...]` and `<t1> | <t2> | ...` forms create instances
    of the same [`typing.Union`][] class. As such, it is recommended to not use this function
    anymore (provided that you only support Python 3.14 or greater), and instead use the
    [`typing_objects.is_union()`][typing_inspection.typing_objects.is_union] function directly:

    ```python
    from typing import Union, get_origin

    from typing_inspection import typing_objects

    typ = int | str  # Or Union[int, str]
    origin = get_origin(typ)
    if typing_objects.is_union(origin):
        ...
    ```
)r   Úis_union©Úobjs    ÚY/var/www/html/gaurav/venv/lib/python3.13/site-packages/typing_inspection/introspection.pyr   r      s   € ô: ×&Ò& sÓ+Ð+ó    c               ó`   • [         R                  " U 5      =(       d    U [        R                  L $ r   )r   r   ÚtypesÚ	UnionTyper   s    r!   r   r   >   s#   € ô: ×&Ò& sÓ+×E¨s´e·o±oÐ/EÐEr"   c               ór   • [        U [        5      (       d"  U [        R                  La  [	        U  S35      egg)zCType check the provided literal value against the legal parameters.zK is not a valid literal value, must be one of: int, bytes, str, Enum, None.N)Ú
isinstanceÚ_literal_allowed_typesr   ÚNoneTypeÚ	TypeError)Úvalues    r!   Ú_literal_type_checkr,   a   s9   € ä�eÔ3×4Ñ4¸Än×F]ÑF]Ò9]Ü˜5˜'Ð!lÐmÓnÐnð :^Ð4r"   FÚeager©Ú
type_checkÚunpack_type_aliasesc            #  óh  #   • US:X  aQ  SnU R                    H>  nU(       a  [        U5        Ub  U[        R                  L a  U(       d  Sv •  SnM:  Uv •  M@     g/ nU R                    H³  n[        R                  " U5      (       a1   UR
                  n[        XaUS9nUR                  S U 5       5        MO  U(       a  [        U5        U[        R                  L a#  UR                  S[        R                  45        M—  UR                  U[        U5      45        Mµ      [        R                  U5      nS U 5        Sh  v•N   g! [         a:    US:X  a  e U(       a  [        U5        UR                  U[        U5      45         GM"  f = f NL! [         a    S	 U 5        Sh  v•N     gf = f7f)
a�  Yield the values contained in the provided [`Literal`][typing.Literal] [special form][].

Args:
    annotation: The [`Literal`][typing.Literal] [special form][] to unpack.
    type_check: Whether to check if the literal values are [legal parameters][literal-legal-parameters].
        Raises a [`TypeError`][] otherwise.
    unpack_type_aliases: What to do when encountering [PEP 695](https://peps.python.org/pep-0695/)
        [type aliases][type-aliases]. Can be one of:

        - `'skip'`: Do not try to parse type aliases. Note that this can lead to incorrect results:
          ```pycon
          >>> type MyAlias = Literal[1, 2]
          >>> list(get_literal_values(Literal[MyAlias, 3], unpack_type_aliases="skip"))
          [MyAlias, 3]
          ```

        - `'lenient'`: Try to parse type aliases, and fallback to `'skip'` if the type alias can't be inspected
          (because of an undefined forward reference).

        - `'eager'`: Parse type aliases and raise any encountered [`NameError`][] exceptions (the default):
          ```pycon
          >>> type MyAlias = Literal[1, 2]
          >>> list(get_literal_values(Literal[MyAlias, 3], unpack_type_aliases="eager"))
          [1, 2, 3]
          ```

Note:
    While `None` is [equivalent to][none] `type(None)`, the runtime implementation of [`Literal`][typing.Literal]
    does not de-duplicate them. This function makes sure this de-duplication is applied:

    ```pycon
    >>> list(get_literal_values(Literal[NoneType, None]))
    [None]
    ```

Example:
    ```pycon
    >>> type Ints = Literal[1, 2]
    >>> list(get_literal_values(Literal[1, Ints], unpack_type_alias="skip"))
    ["a", Ints]
    >>> list(get_literal_values(Literal[1, Ints]))
    [1, 2]
    >>> list(get_literal_values(Literal[1.0], type_check=True))
    Traceback (most recent call last):
    ...
    TypeError: 1.0 is not a valid literal value, must be one of: int, bytes, str, Enum, None.
    ```
ÚskipFNTr.   c              3  ó8   #   • U H  o[        U5      4v •  M     g 7f©N)Útype)Ú.0Úas     r!   Ú	<genexpr>Ú%get_literal_values.<locals>.<genexpr>Å   s   é € Ð*JÁ¸A¬t°A«w­<Âùs   ‚r-   c              3  ó(   #   • U H	  u  pUv •  M     g 7fr4   © ©r6   ÚpÚ_s      r!   r8   r9   Ô   s   é € Ð*¡c™d˜a�¢cùó   ‚c              3  ó(   #   • U H	  u  pUv •  M     g 7fr4   r;   r<   s      r!   r8   r9   Ò   s   é € Ð6¡o™d˜a�¢oùr?   )Ú__args__r,   r   r)   Úis_typealiastypeÚ	__value__r   ÚextendÚ	NameErrorÚappendr5   ÚdictÚfromkeysr*   )	Ú
annotationr/   r0   Ú	_has_noneÚargÚvalues_and_typeÚalias_valueÚsub_argsÚdcts	            r!   r   r   g   s‡  é € ðt ˜fÓ$Øˆ	ð ×&Ô&ˆCÞÜ# CÔ(Ø‰{˜c¤^×%<Ñ%<Ò<Þ Ø’JØ ’	à”	ò 'ð 8:ˆà×&Ô&ˆCô
 ×.Ò.¨s×3Ñ3ðKØ"%§-¡-�Kô  2Ø#ÐPcñ �Hð $×*Ñ*Ñ*JÁÓ*JÖJæÜ'¨Ô,Øœ.×1Ñ1Ò1Ø#×*Ñ*¨D´.×2IÑ2IÐ+JÖKà#×*Ñ*¨C´°c³Ð+;Ö<ñ5 'ð8	+Ü—-‘- Ó0ˆCñ
 +¡cÓ*×*Ñ*øô5 !ó =Ø*¨gÓ5Øæ!Ü+¨CÔ0Ø#×*Ñ*¨C´°c³Ð+;×<Ð<ð=úñ4 +øô	 ó 	7á6¡oÓ6×6Ó6ð	7üsg   ‚BF2ÂEÂBF2Ä F Ä5F2ÅFÅF2Å?FÆF2Æ
FÆF2ÆF/Æ&F)Æ'F/Æ,F2Æ.F/Æ/F2)ÚrequiredÚnot_requiredÚ	read_onlyÚ	class_varÚinit_varÚfinalr   r   úset[Qualifier]Ú_all_qualifiersc                  ó¬   • \ rS rSrSr\" 5       r \" 5       r \" 5       r \" 5       r	 \" 5       r
 \" 5       r \" 5       r \" 5       r \SS j5       rSrg)r   éß   z”The source of an annotation, e.g. a class or a function.

Depending on the source, different [type qualifiers][type qualifier] may be (dis)allowed.
c                ó|  • U [         R                  L a  S1$ U [         R                  L a  SS1$ U [         R                  L a  1 Sk$ U [         R                  L a  1 Sk$ U [         R
                  [         R                  [         R                  4;   a
  [        5       $ U [         R                  L a  [        $ [        U 5        g)zIThe allowed [type qualifiers][type qualifier] for this annotation source.rU   rS   >   rU   rT   rS   >   rP   rR   rQ   N)r   ÚASSIGNMENT_OR_VARIABLEÚCLASSÚ	DATACLASSÚ
TYPED_DICTÚNAMED_TUPLEÚFUNCTIONÚBAREÚsetÚANYrW   r   ©Úselfs    r!   Úallowed_qualifiersÚ#AnnotationSource.allowed_qualifiers<  s§   € ð Ô#×:Ñ:Ò:Ø�9ÐØÔ%×+Ñ+Ò+Ø˜[Ð)Ð)ØÔ%×/Ñ/Ò/Ú5Ð5ØÔ%×0Ñ0Ò0Ú<Ð<ØÔ&×2Ñ2Ô4D×4MÑ4MÔO_×OdÑOdÐeÓeÜ“5ˆLØÔ%×)Ñ)Ò)Ü"Ð"ä˜Õr"   r;   N)ÚreturnrV   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r[   r\   r]   r^   r_   r`   rc   ra   Úpropertyrf   Ú__static_attributes__r;   r"   r!   r   r   ß   sŒ   † ññ
 "›VÐðñ ‹F€Eð	ñ “€Ið
ñ “€Jð
ñ “&€Kð	ñ ‹v€Hðñ ‹&€Cðñ
 ‹6€Dðð
 óó ór"   r   c                  ó0   • \ rS rSr% SrS\S'    SS jrSrg)	r   iP  z-The provided [type qualifier][] is forbidden.r   Ú	qualifierc               ó   • Xl         g r4   ©rq   )re   rq   s     r!   Ú__init__ÚForbiddenQualifier.__init__V  s   € Ø"�r"   rs   N)rq   r   rh   ÚNone)ri   rj   rk   rl   rm   Ú__annotations__rt   ro   r;   r"   r!   r   r   P  s   ‡ Ù7àÓØ"÷#r"   r   c                  ó6   • \ rS rSr\" 5       rSS jrSS jrSrg)Ú_UnknownTypeEnumiZ  c                ó   • g)NÚUNKNOWNr;   rd   s    r!   Ú__str__Ú_UnknownTypeEnum.__str__]  s   € Ør"   c                ó   • g)Nz	<UNKNOWN>r;   rd   s    r!   Ú__repr__Ú_UnknownTypeEnum.__repr__`  s   € Ør"   r;   N)rh   Ústr)	ri   rj   rk   rl   r   r{   r|   r   ro   r;   r"   r!   ry   ry   Z  s   † Ù‹f€Gô÷r"   ry   Ú_UnknownTypec                  ó<   • \ rS rSr% SrS\S'    S\S'    S\S'   S	rg
)r   ik  z'The result of the inspected annotation.zAny | _UnknownTyper5   rV   Ú
qualifiersz	list[Any]Úmetadatar;   N)ri   rj   rk   rl   rm   rw   ro   r;   r"   r!   r   r   k  s$   ‡ Ù1à
Óðð ÓØJàÓÚ!r"   r   r2   ©r0   c              óÀ  • UR                   n[        5       n/ n [        XS9u  pU(       a  Xe-   nM  [        U 5      nUGb„  [        R
                  " U5      (       a3  SU;  a  [        S5      eUR                  S5        U R                  S   n GO‰[        R                  " U5      (       a3  SU;  a  [        S5      eUR                  S5        U R                  S   n GO;[        R                  " U5      (       a2  SU;  a  [        S5      eUR                  S5        U R                  S   n Oî[        R                  " U5      (       a2  SU;  a  [        S5      eUR                  S5        U R                  S   n O¡[        R                  " U5      (       a2  SU;  a  [        S5      eUR                  S5        U R                  S   n OTOV[        U [        5      (       a=  SU;  a  [        S5      eUR                  S5        [        [         U R"                  5      n OOGM  [        R                  " U 5      (       a)  SU;  a  [        S5      eUR                  S5        [$        n Ou[        R
                  " U 5      (       a)  SU;  a  [        S5      eUR                  S5        [$        n O1U [        L a(  SU;  a  [        S5      eUR                  S5        [$        n ['        XU5      $ )	ay	  Inspect an [annotation expression][], extracting any [type qualifier][] and metadata.

An [annotation expression][] is a [type expression][] optionally surrounded by one or more
[type qualifiers][type qualifier] or by [`Annotated`][typing.Annotated]. This function will:

- Unwrap the type expression, keeping track of the type qualifiers.
- Unwrap [`Annotated`][typing.Annotated] forms, keeping track of the annotated metadata.

Args:
    annotation: The annotation expression to be inspected.
    annotation_source: The source of the annotation. Depending on the source (e.g. a class), different type
        qualifiers may be (dis)allowed. To allow any type qualifier, use
        [`AnnotationSource.ANY`][typing_inspection.introspection.AnnotationSource.ANY].
    unpack_type_aliases: What to do when encountering [PEP 695](https://peps.python.org/pep-0695/)
        [type aliases][type-aliases]. Can be one of:

        - `'skip'`: Do not try to parse type aliases (the default):
          ```pycon
          >>> type MyInt = Annotated[int, 'meta']
          >>> inspect_annotation(MyInt, annotation_source=AnnotationSource.BARE, unpack_type_aliases='skip')
          InspectedAnnotation(type=MyInt, qualifiers={}, metadata=[])
          ```

        - `'lenient'`: Try to parse type aliases, and fallback to `'skip'` if the type alias
          can't be inspected (because of an undefined forward reference):
          ```pycon
          >>> type MyInt = Annotated[Undefined, 'meta']
          >>> inspect_annotation(MyInt, annotation_source=AnnotationSource.BARE, unpack_type_aliases='lenient')
          InspectedAnnotation(type=MyInt, qualifiers={}, metadata=[])
          >>> Undefined = int
          >>> inspect_annotation(MyInt, annotation_source=AnnotationSource.BARE, unpack_type_aliases='lenient')
          InspectedAnnotation(type=int, qualifiers={}, metadata=['meta'])
          ```

        - `'eager'`: Parse type aliases and raise any encountered [`NameError`][] exceptions.

Returns:
    The result of the inspected annotation, where the type expression, used qualifiers and metadata is stored.

Example:
    ```pycon
    >>> inspect_annotation(
    ...     Final[Annotated[ClassVar[Annotated[int, 'meta_1']], 'meta_2']],
    ...     annotation_source=AnnotationSource.CLASS,
    ... )
    ...
    InspectedAnnotation(type=int, qualifiers={'class_var', 'final'}, metadata=['meta_1', 'meta_2'])
    ```
r†   rS   r   rU   rP   rQ   rR   rT   )rf   rb   Ú_unpack_annotatedr   r   Úis_classvarr   ÚaddrA   Úis_finalÚis_requiredÚis_notrequiredÚis_readonlyr'   r   r   r	   r5   r{   r   )rI   Úannotation_sourcer0   rf   r„   r…   Ú_metaÚorigins           r!   r   r   ƒ  s„  € ðp +×=Ñ=ÐÜ!$£€JØ€Hà
Ü-¨jÑbÑˆ
ÞØÑ'ˆHÙä˜JÓ'ˆØÒÜ×)Ò)¨&×1Ñ1ØÐ&8Ó8Ü,¨[Ó9Ð9Ø—‘˜{Ô+Ø'×0Ñ0°Ñ3’
Ü×(Ò(¨×0Ñ0ØÐ"4Ó4Ü,¨WÓ5Ð5Ø—‘˜wÔ'Ø'×0Ñ0°Ñ3’
Ü×+Ò+¨F×3Ñ3ØÐ%7Ó7Ü,¨ZÓ8Ð8Ø—‘˜zÔ*Ø'×0Ñ0°Ñ3‘
Ü×.Ò.¨v×6Ñ6Ø!Ð);Ó;Ü,¨^Ó<Ð<Ø—‘˜~Ô.Ø'×0Ñ0°Ñ3‘
Ü×+Ò+¨F×3Ñ3ØÐ&8Ó8Ü,¨^Ó<Ð<Ø—‘˜{Ô+Ø'×0Ñ0°Ñ3‘
ð Ü˜
¤G×,Ñ,ØÐ!3Ó3Ü(¨Ó4Ð4Ø�N‰N˜:Ô&Üœc :§?¡?Ó3‰JàòU ôZ ×Ò˜z×*Ñ*ØÐ,Ó,Ü$ WÓ-Ð-Ø�‰�wÔÜ‰
Ü	×	#Ò	# J×	/Ñ	/ØÐ0Ó0Ü$ [Ó1Ð1Ø�‰�{Ô#Ü‰
Ø	”wÒ	ØÐ/Ó/Ü$ ZÓ0Ð0Ø�‰�zÔ"Üˆ
ä˜z°xÓ@Ð@r"   c                óz  • [        U 5      nU(       aO  [        R                  " U5      (       a4  U R                  n[	        U R
                  5      n[        XASS9u  pFXe-   nXE4$ [        R                  " U 5      (       a'   U R                  n[        XqSS9u  p…U(       a  X…4$ U / 4$ [        R                  " U5      (       a6   UR                  n XpR                     n[        XqSS9u  p…U(       a  X…4$ U / 4$ U / 4$ ! [         a    US:X  a  e  U / 4$ f = f! [         a     NDf = f! [         a    US:X  a  e  U / 4$ f = f)NF©r0   Úcheck_annotatedTr-   )r   r   Úis_annotatedÚ
__origin__ÚlistÚ__metadata__Ú_unpack_annotated_innerrB   rC   rE   rA   r*   )	rI   r0   r”   r‘   Úannotated_typer…   Úsub_metar+   Útyps	            r!   r™   r™   ÿ  s�  € ô ˜
Ó#€FÞœ>×6Ò6°v×>Ñ>Ø#×.Ñ.ˆÜ˜
×/Ñ/Ó0ˆô
 $;ØÐUZñ$
Ñ ˆð Ñ&ˆØÐ'Ð'Ü	×	(Ò	(¨×	4Ñ	4ð	"Ø×(Ñ(ˆEô
 4ØÐPTñ‰MˆCö ð �}Ð$Ø˜r�>Ð!Ü	×	(Ò	(¨×	0Ñ	0ð	"Ø×$Ñ$ˆEðð ×1Ñ1Ñ2�ô
 4ØÐPTñ‰MˆCö Ø�}Ð$Ø˜r�>Ð!à�rˆ>ÐøôY ó 	Ø" gÓ-Øð .ðV �rˆ>ÐðY	ûôB ó ñ ðûô ó 	Ø" gÓ-Øð .ð0 �rˆ>Ðð3	ús6   Á>C9 Ã D# ÃD Ã9DÄDÄ
D ÄD Ä#D:Ä9D:c              ó´   • US:X  aI  [         R                  " [        U 5      5      (       a!  U R                  [	        U R
                  5      4$ U / 4$ [        XSS9$ )Nr2   Tr“   )r   r•   r   r–   r—   r˜   r™   )rI   r0   s     r!   rˆ   rˆ   B  sV   € ð ˜fÓ$Ü×&Ò&¤z°*Ó'=×>Ñ>Ø×(Ñ(¬$¨z×/FÑ/FÓ*GÐGÐGà˜r�>Ð!ä" :ÐhlÑmÐmr"   )r    r	   rh   Úbool)r+   r	   rh   rv   )rI   r	   r/   rž   r0   ú#Literal['skip', 'lenient', 'eager']rh   zGenerator[Any])rI   r	   r�   r   r0   rŸ   rh   r   )rI   r	   r0   zLiteral['lenient', 'eager']r”   rž   rh   útuple[Any, list[Any]])rI   r	   r0   rŸ   rh   r    )2rm   Ú
__future__r   Úsysr$   Úcollections.abcr   Údataclassesr   Úenumr   r   r   Útypingr	   r
   r   r   r   Útyping_extensionsr   r   r   Ú r   Ú__all__Úversion_infor   ÚintÚbytesr�   rž   r)   r(   r,   r   r   rw   rb   rW   r   Ú	Exceptionr   ry   r{   r‚   r   r   r™   rˆ   r;   r"   r!   Ú<module>r®      sÅ  ðÚ Kå "ã 
Û Ý %Ý ß $Ñ $ß <Õ <ç @Ñ @å ð€ð ×Ñ�wÓõ,ôDFð@ ˜u™ sÑ*¨TÑ1°DÑ8¸>×;RÑ;RÑRÐ ôoð Ø?Fñm+Øðm+ð ð	m+ð
 =ðm+ð õm+ð` ÐhÑi€	ˆ9Ó iØ á"%¡h¨yÓ&9Ó":€�Ó :ô
n�wô nôb#˜ô #ô�tô ð ×
"Ñ
"€Ø Cà!Ð"2×":Ñ":Ñ;€ˆiÓ ;Ø Zô"˜*ô "ð: @FñyAØðyAð (ð	yAð
 =ðyAð õyAðx?Øð?Ø*Eð?ØX\ð?àô?ðH W^ñ	nØð	nØ0Sð	nàö	nr"   