Ë
    S>{iX  ã                  ó*  — U d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZ ddlmZmZmZmZ ddlmZmZmZmZ d	d
lmZ dZej4                  dk\  sej4                  dk  rd(d„Znd(d„Zd)d„Zdddœ	 	 	 	 	 	 	 d*d„Zed   Zded<   	  e  ee«      «      Z!ded<    G d„ de«      Z" G d„ de#«      Z$ G d„ de
«      Z%e%jL                  Z&	 ee%jL                     Z'ded <   	  G d!„ d"e«      Z(d#d$œ	 	 	 	 	 	 	 d+d%„Z)	 	 	 	 	 	 	 	 d,d&„Z*dd$œ	 	 	 	 	 d-d'„Z+y).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               ó,   — t        j                  | «      S ©aè  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    ú]/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/typing_inspection/introspection.pyr   r      s   € ô: ×&Ñ& sÓ+Ð+ó    c               óT   — t        j                  | «      xs | t        j                  u S r   )r   r   ÚtypesÚ	UnionTyper    s    r"   r   r   >   s#   € ô: ×&Ñ& sÓ+ÒE¨s´e·o±oÐ/EÐEr#   c          	     ó®   — t        | t        t        t        t        t
        t        j                  f«      s!| t        j                  urt        | › d�«      ‚yy)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   ^   sM   € ô �uœs¤E¬3´´d¼N×<SÑ<SÐTÔUØœ×0Ñ0Ñ0ä˜5˜'Ð!lÐmÓnÐnð 1ð Vr#   FÚeager©Ú
type_checkÚunpack_type_aliasesc            #  ó  K  — |dk(  rBd}| j                   D ]0  }|rt        |«       |�|t        j                  u r	|sd–— d}Œ-|–— Œ2 yg }| j                   D ]¨  }t        j                  |«      r4	 |j
                  }t        |||¬«      }|j                  d„ |D «       «       ŒL|rt        |«       |t        j                  u r"|j                  dt        j                  f«       Œ�|j                  |t        |«      f«       Œª 	 t        j                  |«      }d„ |D «       E d{  –—†  y# t        $ r3 |dk(  r‚ |rt        |«       |j                  |t        |«      f«       Y �Œw xY w7 ŒD# t        $ r d	„ |D «       E d{  –—†7   Y yw xY w­w)
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  ó6   K  — | ]  }|t        |«      f–— Œ y ­w©N)Útype)Ú.0Úas     r"   ú	<genexpr>z%get_literal_values.<locals>.<genexpr>Å   s   è ø€ Ò*J¸A¨A¬t°A«w¬<Ñ*Jùs   ‚r1   c              3  ó&   K  — | ]	  \  }}|–— Œ y ­wr8   © ©r:   ÚpÚ_s      r"   r<   z%get_literal_values.<locals>.<genexpr>Ô   s   è ø€ Ò*™d˜a œÑ*ùó   ‚c              3  ó&   K  — | ]	  \  }}|–— Œ y ­wr8   r>   r?   s      r"   r<   z%get_literal_values.<locals>.<genexpr>Ò   s   è ø€ Ò6™d˜a œÑ6ùrB   )Ú__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ð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   ‚A.FÁ1D+Á=BFÄE, ÄFÄ%E*Ä&FÄ+8E'Å#FÅ&E'Å'FÅ,F
ÆFÆF
ÆFÆ	F
Æ
F)ÚrequiredÚnot_requiredÚ	read_onlyÚ	class_varÚinit_varÚfinalr   r   úset[Qualifier]Ú_all_qualifiersc                  ó¢   — e Zd ZdZ e«       Z	  e«       Z	  e«       Z	  e«       Z	  e«       Z		  e«       Z
	  e«       Z	  e«       Z	 edd„«       Zy)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                ón  — | t         j                  u rdhS | t         j                  u rddhS | t         j                  u rh d£S | t         j                  u rh d£S | t         j
                  t         j                  t         j                  fv r
t        «       S | t         j                  u rt        S t        | «       y)zIThe allowed [type qualifiers][type qualifier] for this annotation source.rX   rV   >   rX   rW   rV   >   rS   rU   rT   N)r   ÚASSIGNMENT_OR_VARIABLEÚCLASSÚ	DATACLASSÚ
TYPED_DICTÚNAMED_TUPLEÚFUNCTIONÚBAREÚsetÚANYrZ   r   ©Úselfs    r"   Úallowed_qualifiersz#AnnotationSource.allowed_qualifiers<  s§   € ð Ô#×:Ñ:Ñ:Ø�9ÐØÔ%×+Ñ+Ñ+Ø˜[Ð)Ð)ØÔ%×/Ñ/Ñ/Ú5Ð5ØÔ%×0Ñ0Ñ0Ú<Ð<ØÔ&×2Ñ2Ô4D×4MÑ4MÔO_×OdÑOdÐeÑeÜ“5ˆLØÔ%×)Ñ)Ñ)Ü"Ð"ä˜Õr#   N)ÚreturnrY   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r]   r^   r_   r`   ra   rb   re   rc   Úpropertyrh   r>   r#   r"   r   r   ß   sŒ   „ ññ
 "›VÐðñ ‹F€Eð	ñ “€Ið
ñ “€Jð
ñ “&€Kð	ñ ‹v€Hðñ ‹&€Cðñ
 ‹6€Dðð
 òó ñr#   r   c                  ó&   — e Zd ZU dZded<   	 dd„Zy)r   z-The provided [type qualifier][] is forbidden.r   Ú	qualifierc               ó   — || _         y r8   )rp   )rg   rp   s     r"   Ú__init__zForbiddenQualifier.__init__V  s	   € Ø"ˆ�r#   N)rp   r   ri   ÚNone)rj   rk   rl   rm   Ú__annotations__rr   r>   r#   r"   r   r   P  s   … Ù7àÓØ"ô#r#   r   c                  ó*   — e Zd Z e«       Zdd„Zdd„Zy)Ú_UnknownTypeEnumc                 ó   — y)NÚUNKNOWNr>   rf   s    r"   Ú__str__z_UnknownTypeEnum.__str__]  s   € Ør#   c                 ó   — y)Nz	<UNKNOWN>r>   rf   s    r"   Ú__repr__z_UnknownTypeEnum.__repr__`  s   € Ør#   N)ri   r+   )rj   rk   rl   r   rx   ry   r{   r>   r#   r"   rv   rv   Z  s   „ Ù‹f€Góôr#   rv   Ú_UnkownTypec                  ó4   — e Zd ZU dZded<   	 ded<   	 ded<   y)	r   z'The result of the inspected annotation.zAny | _UnkownTyper9   rY   Ú
qualifiersz	list[Any]ÚmetadataN)rj   rk   rl   rm   rt   r>   r#   r"   r   r   k  s$   … Ù1à
Óðð ÓØJàÓØ!r#   r   r6   ©r4   c              ó:  — |j                   }t        «       }g }	 t        | |¬«      \  } }|r||z   }Œt        | «      }|��\t	        j
                  |«      r1d|vrt        d«      ‚|j                  d«       | j                  d   } �nbt	        j                  |«      r1d|vrt        d«      ‚|j                  d«       | j                  d   } �nt	        j                  |«      r0d|vrt        d«      ‚|j                  d«       | j                  d   } n×t	        j                  |«      r0d|vrt        d«      ‚|j                  d«       | j                  d   } n’t	        j                  |«      r0d|vrt        d«      ‚|j                  d«       | j                  d   } nMnNt        | t        «      r;d|vrt        d«      ‚|j                  d«       t        t         | j"                  «      } nn�ŒÐt	        j                  | «      r'd|vrt        d«      ‚|j                  d«       t$        } njt	        j
                  | «      r'd|vrt        d«      ‚|j                  d«       t$        } n.| t        u r&d|vrt        d«      ‚|j                  d«       t$        } t'        | ||«      S )	a
  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€   rV   r   rX   rS   rT   rU   rW   )rh   rd   Ú_unpack_annotatedr   r   Úis_classvarr   ÚaddrD   Úis_finalÚis_requiredÚis_notrequiredÚis_readonlyr(   r   r   r	   r9   rx   r   )rL   Úannotation_sourcer4   rh   r~   r   Ú_metaÚorigins           r"   r   r   ƒ  su  € ðp +×=Ñ=ÐÜ!$£€JØ€Hà
Ü-¨jÐNaÔbÑˆ
�EÙØ˜xÑ'ˆHØä˜JÓ'ˆØÑÜ×)Ñ)¨&Ô1ØÐ&8Ñ8Ü,¨[Ó9Ð9Ø—‘˜{Ô+Ø'×0Ñ0°Ñ3’
Ü×(Ñ(¨Ô0ØÐ"4Ñ4Ü,¨WÓ5Ð5Ø—‘˜wÔ'Ø'×0Ñ0°Ñ3’
Ü×+Ñ+¨FÔ3ØÐ%7Ñ7Ü,¨ZÓ8Ð8Ø—‘˜zÔ*Ø'×0Ñ0°Ñ3‘
Ü×.Ñ.¨vÔ6Ø!Ð);Ñ;Ü,¨^Ó<Ð<Ø—‘˜~Ô.Ø'×0Ñ0°Ñ3‘
Ü×+Ñ+¨FÔ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                óV  — t        | «      }|rPt        j                  |«      r;| j                  }t	        | j
                  «      }t        ||d¬«      \  }}||z   }||fS t        j                  | «      r(	 | j                  }t        ||d¬«      \  }}|r||fS | g fS t        j                  |«      r8	 |j                  }	 || j                     }t        ||d¬«      \  }}|r||fS | g fS | g fS # t        $ r |dk(  r‚ Y | g fS w xY w# t        $ r Y ŒBw xY w# t        $ r |dk(  r‚ Y | g fS w xY w)NF©r4   Úcheck_annotatedTr1   )r   r   Úis_annotatedÚ
__origin__ÚlistÚ__metadata__Ú_unpack_annotated_innerrE   rF   rH   rD   r.   )	rL   r4   rŽ   r‹   Úannotated_typer   Úsub_metar/   Útyps	            r"   r“   r“   ÿ  sŸ  € ô ˜
Ó#€FÙœ>×6Ñ6°vÔ>Ø#×.Ñ.ˆÜ˜
×/Ñ/Ó0ˆô
 $;ØÐ0CÐUZô$
Ñ ˆ˜ð ˜hÑ&ˆØ˜xÐ'Ð'Ü	×	(Ñ	(¨Ô	4ð	"Ø×(Ñ(ˆEô
 4ØÐ+>ÐPTô‰MˆC�ñ ð ˜H�}Ð$Ø˜r�>Ð!Ü	×	(Ñ	(¨Ô	0ð	"Ø×$Ñ$ˆEðð ˜j×1Ñ1Ñ2�ô
 4ØÐ+>ÐPTô‰MˆC�ñ Ø˜H�}Ð$Ø˜r�>Ð!à�rˆ>ÐøôY ò 	Ø" gÒ-Øð .ðV �rˆ>ÐðY	ûôB ò ñ ðûô ò 	Ø" gÒ-Øð .ð0 �rˆ>Ðð3	ús6   Á4C, Â1D Â>D Ã,DÄ DÄ	DÄDÄD(Ä'D(c              ó®   — |dk(  rCt        j                  t        | «      «      r!| j                  t	        | j
                  «      fS | g fS t        | |d¬«      S )Nr6   Tr�   )r   r�   r   r�   r‘   r’   r“   )rL   r4   s     r"   r‚   r‚   B  sV   € ð ˜fÒ$Ü×&Ñ&¤z°*Ó'=Ô>Ø×(Ñ(¬$¨z×/FÑ/FÓ*GÐGÐGà˜r�>Ð!ä" :ÐCVÐhlÔmÐmr#   )r!   r	   ri   r,   )r/   r	   ri   rs   )rL   r	   r3   r,   r4   ú#Literal['skip', 'lenient', 'eager']ri   zGenerator[Any])rL   r	   r‰   r   r4   r˜   ri   r   )rL   r	   r4   zLiteral['lenient', 'eager']rŽ   r,   ri   útuple[Any, list[Any]])rL   r	   r4   r˜   ri   r™   ),rm   Ú
__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   rt   rd   rZ   r   Ú	Exceptionr   rv   rx   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#   