ó
    ”¬éhX  ã                  óB  • % 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  SSKJrJrJrJr  S	S
KJr  Sr\R4                  S:¼  d  \R4                  S:  a  S(S jrOS(S j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%\%RL                  r& \\%RL                     r'S\S '     " S! S"\5      r(S#S$.       S+S% jjr)        S,S& jr*SS$.     S-S' jjr+g).zEHigh-level introspection utilities, used to inspect type annotations.é    )ÚannotationsN)Ú	Generator)ÚInitVar)ÚEnumÚIntEnumÚauto)ÚAnyÚLiteralÚ
NamedTupleÚcast)Ú	TypeAliasÚassert_neverÚget_argsÚ
get_originé   )Útyping_objects)ÚAnnotationSourceÚForbiddenQualifierÚInspectedAnnotationÚ	QualifierÚget_literal_valuesÚinspect_annotationÚis_union_origin)é   é   )r   é
   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    Ú\/home/mande/repo/quber/.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          	     óº   • [        U [        [        [        [        [
        [        R                  4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ÚintÚbytesÚstrÚboolr   r   ÚNoneTypeÚ	TypeError)Úvalues    r"   Ú_literal_type_checkr0   ^   sP   € ô �uœs¤E¬3´´d¼N×<SÑ<SÐT×UÑUØœ×0Ñ0Ò0ä˜5˜'Ð!lÐmÓnÐnð 1ð Vr#   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.
    ```
ÚskipFNTr2   c              3  ó:   #   • 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   ‚r1   c              3  ó*   #   • U  H	  u  pUv •  M     g 7fr8   © ©r:   ÚpÚ_s      r"   r<   r=   Ô   s   é € Ð*¢c™d˜a�¢cùó   ‚c              3  ó*   #   • U  H	  u  pUv •  M     g 7fr8   r?   r@   s      r"   r<   r=   Ò   s   é € Ð6¢o™d˜a�¢oùrC   )Ú__args__r0   r   r-   Úis_typealiastypeÚ	__value__r   ÚextendÚ	NameErrorÚappendr9   ÚdictÚfromkeysr.   )	Ú
annotationr3   r4   Ú	_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.rY   rW   >   rY   rX   rW   >   rT   rV   rU   N)r   ÚASSIGNMENT_OR_VARIABLEÚCLASSÚ	DATACLASSÚ
TYPED_DICTÚNAMED_TUPLEÚFUNCTIONÚBAREÚsetÚANYr[   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)ÚreturnrZ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r_   r`   ra   rb   rc   rd   rg   re   Úpropertyrj   Ú__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 r8   ©ru   )ri   ru   s     r"   Ú__init__ÚForbiddenQualifier.__init__V  s   € Ø"�r#   rw   N)ru   r   rl   ÚNone)rm   rn   ro   rp   rq   Ú__annotations__rx   rs   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?   rh   s    r"   Ú__str__Ú_UnknownTypeEnum.__str__]  s   € Ør#   c                ó   • g)Nz	<UNKNOWN>r?   rh   s    r"   Ú__repr__Ú_UnknownTypeEnum.__repr__`  s   € Ør#   r?   N)rl   r+   )	rm   rn   ro   rp   r   r   r€   rƒ   rs   r?   r#   r"   r}   r}   Z  s   † Ù‹f€Gô÷r#   r}   Ú_UnkownTypec                  ó<   • \ 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 | _UnkownTyper9   rZ   Ú
qualifiersz	list[Any]Úmetadatar?   N)rm   rn   ro   rp   rq   r{   rs   r?   r#   r"   r   r   k  s$   ‡ Ù1à
Óðð ÓØJàÓÚ!r#   r   r6   ©r4   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‰   rW   r   rY   rT   rU   rV   rX   )rj   rf   Ú_unpack_annotatedr   r   Úis_classvarr   ÚaddrE   Úis_finalÚis_requiredÚis_notrequiredÚis_readonlyr(   r   r   r	   r9   r   r   )rM   Úannotation_sourcer4   rj   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©r4   Úcheck_annotatedTr1   )r   r   Úis_annotatedÚ
__origin__ÚlistÚ__metadata__Ú_unpack_annotated_innerrF   rG   rI   rE   r.   )	rM   r4   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$ )Nr6   Tr–   )r   r˜   r   r™   rš   r›   rœ   )rM   r4   s     r"   r‹   r‹   B  sV   € ð ˜fÓ$Ü×&Ò&¤z°*Ó'=×>Ñ>Ø×(Ñ(¬$¨z×/FÑ/FÓ*GÐGÐGà˜r�>Ð!ä" :ÐhlÑmÐmr#   )r!   r	   rl   r,   )r/   r	   rl   rz   )rM   r	   r3   r,   r4   ú#Literal['skip', 'lenient', 'eager']rl   zGenerator[Any])rM   r	   r’   r   r4   r¡   rl   r   )rM   r	   r4   zLiteral['lenient', 'eager']r—   r,   rl   útuple[Any, list[Any]])rM   r	   r4   r¡   rl   r¢   ),rq   Ú
__future__r   Úsysr%   Úcollections.abcr   Údataclassesr   Úenumr   r   r   Útypingr	   r
   r   r   Útyping_extensionsr   r   r   r   Ú r   Ú__all__Úversion_infor   r0   r   r   r{   rf   r[   r   Ú	Exceptionr   r}   r   r…   r   r   rœ   r‹   r?   r#   r"   Ú<module>r®      s¬  ðÚ Kå "ã 
Û Ý %Ý ß $Ñ $ß 1Ó 1ç KÓ Kå ð€ð ×Ñ�wÓ #×"2Ñ"2°WÓ"<õ,ôDFô@oð Ø?Fñm+Øðm+ð ð	m+ð
 =ðm+ð õm+ð` ÐhÑi€	ˆ9Ó iØ á"%¡h¨yÓ&9Ó":€�Ó :ô
n�wô nôb#˜ô #ô�tô ð ×
"Ñ
"€Ø Cà Ð!1×!9Ñ!9Ñ:€ˆYÓ :Ø Zô"˜*ô "ð: @FñyAØðyAð (ð	yAð
 =ðyAð õyAðx?Øð?Ø*Eð?ØX\ð?àô?ðH W^ñ	nØð	nØ0Sð	nàö	nr#   