
    hQ                    &   % S r SSKJr  SSKrSSKrSSKJr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\R6                  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&\&RN                  r' \\&RN                     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Sequence)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)   
   c               `    [         R                  " U 5      =(       d    U [        R                  L $ zReturn whether the provided origin is the union form.

```pycon
>>> is_union_origin(typing.Union)
True
>>> is_union_origin(get_origin(int | str))
True
```
)r   is_uniontypes	UnionTypeobjs    Q/var/www/html/env/lib/python3.13/site-packages/typing_inspection/introspection.pyr   r      s#     &&s+Eseoo/EE    c               .    [         R                  " U 5      $ r   )r   r   r"   s    r$   r   r   *   s     &&s++r%   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   7   sP     usE3dN<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AtAw<s   r1   c              3  *   #    U  H	  u  pUv   M     g 7fr8    r:   p_s      r$   r<   r=      s     *cdac   c              3  *   #    U  H	  u  pUv   M     g 7fr8   r?   r@   s      r$   r<   r=      s     6odaorC   )__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   @   s    t f$	 &&C#C({c^%<%<< J 		 ' 8:&&C
 ..s33K"%--K  2#Pc H $***J*JJ',.111#**D.2I2I+JK#**Cc+;<5 '8	+--0C
 +c***5 ! =*g5!+C0#**Cc+;<<=4 +	  	76o666	7sg   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      zThe 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24D4M4MO_OdOdee5L%)))""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 FE	 I
 J
 &K	 vH &C
 6D
  r%   r   c                  0    \ rS rSr% SrS\S'    SS jrSrg)	r   i)  z-The provided [type qualifier][] is forbidden.r   	qualifierc                   Xl         g r8   ru   )ri   ru   s     r$   __init__ForbiddenQualifier.__init__/  s    "r%   rw   N)ru   r   rl   None)rm   rn   ro   rp   rq   __annotations__rx   rs   r?   r%   r$   r   r   )  s    7"#r%   r   c                  6    \ rS rSr\" 5       rSS jrSS jrSrg)_UnknownTypeEnumi3  c                    g)NUNKNOWNr?   rh   s    r$   __str___UnknownTypeEnum.__str__6  s    r%   c                    g)Nz	<UNKNOWN>r?   rh   s    r$   __repr___UnknownTypeEnum.__repr__9  s    r%   r?   N)rl   r+   )	rm   rn   ro   rp   r	   r   r   r   rs   r?   r%   r$   r}   r}   3  s    fGr%   r}   _UnkownTypec                  <    \ rS rSr% SrS\S'    S\S'    S\S'   S	rg
)r   iD  z'The result of the inspected annotation.zAny | _UnkownTyper9   rZ   
qualifierszSequence[Any]metadatar?   N)rm   rn   ro   rp   rq   r{   rs   r?   r%   r$   r   r   D  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NN:&c:??3JU Z z**,,$W--w
		#	#J	/	/00$[11{#
	w	//$Z00z"
zx@@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  pU(       a  X4$ U / 4$ [        R                  " U5      (       a6   UR                  n XpR                     n[        XqSS9u  pU(       a  X4$ 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6v>>#..
//0
 $;UZ$
  &''		(	(	4	4	"((E
 4PTMC  }$r>!		(	(	0	0	"$$E 112
 4PTMC }$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     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   r   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
F
,o ?Fm+m+ 	m+
 =m+ m+` hi	9 i "%hy&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%   