a
    “˜ëjC  ã                N   @   sä  U d Z ddlZddlZddlZddlZddlZddlZddlm	Z	 ddl
mZmZ ddlmZmZ ddlZddlmZmZmZmZ dZejdd… d	kZeeed
œdd„Zeeed
œdd„Zejd	krÔddl
mZ nedƒZeddƒZde_ eddƒZde_ eddƒZde_ eddƒZde_ eddƒZde_ edd ƒZ d!e _ ed"d#ƒZ!d$e!_ ed%d&ƒZ"d'e"_ ed(d)ƒZ#d*e#_ ed+d,ƒZ$d-e$_ ed.d/ƒZ%d0e%_ ed1d2ƒZ&d3e&_ ee'd4œd5d6„Z(ed7d8ƒZ)d9e)_ ed:d;ƒZ*d<e*_ ejd	k�räed=d>ƒZ+nee'd4œd?d>„Z+d@e+_ edAdBƒZ,dCe,_ edDdEƒZ-dFe-_ edGdHƒZ.dIe._ edJdKƒZ/dLe/_ edMdNƒZ0dOe0_ edPdQƒZ1dRe1_ edSdTƒZ2dUe2_ edVdWƒZ3dXe3_ edYdZƒZ4d[e4_ ed\d]ƒZ5d^e5_ ed_d`ƒZ6dae6_ edbdcƒZ7dde7_ ededfƒZ8e�rÜedgd4œdhdi„Z9n
edediƒZ9dje9_ edkdlƒZ:dme:_ ejdnk�redod4œdpdq„Z;nedod4œdrdq„Z;dse;_ ej<ej=j<ej>ej=j>ej?ej=j?ej@ej=j@ejAej=jAejBej=jBejCej=jCejDej=jDejEej=jEejFej=jFejGej=jGejHej=jHejIej=jJejKej=jKejLej=jLejMej=jMejNej=jNejOej=jOejPeQejReSejTejUejJeVejWeXejYej=jYejZej=jZej[ej=j[ej\ej=j\ej]e^ej_ej`ejaejaejbejbejcejcejdej=jdejeej=jeejfeejgejgejhejhejiejjejkejli'Zmee^eee f  endt< eSem o¡ ƒD ]*\ZpZqereepjsdƒ Ztdu�r´eqemet< �q´dS )uzÏLow-level introspection utilities for [`typing`][] members.

The provided functions in this module check against both the [`typing`][] and [`typing_extensions`][]
variants, if they exists and are different.
é    N)Údedent)ÚFunctionTypeÚGenericAlias)ÚAnyÚFinal)ÚLiteralStringÚTypeAliasTypeÚTypeIsÚ
deprecated)!ÚDEPRECATED_ALIASESÚNoneTypeÚis_annotatedÚis_anyÚis_classvarÚis_concatenateÚis_deprecatedÚis_finalÚis_forwardrefÚ
is_genericÚ
is_literalÚis_literalstringÚis_namedtupleÚis_neverÚ
is_newtypeÚis_nodefaultÚis_noextraitemsÚis_noreturnÚis_notrequiredÚis_paramspecÚis_paramspecargsÚis_paramspeckwargsÚis_readonlyÚis_requiredÚis_selfÚis_typealiasÚis_typealiastypeÚis_typeguardÚ	is_typeisÚ
is_typevarÚis_typevartupleÚis_unionÚ	is_unpacké   )é   é
   )ÚmemberÚfunction_nameÚreturnc                 C   s´   t t| ƒ}t t| ƒ}|rN|rNtt| ƒtt| ƒu r<d| › �}qzd| › d| › �}n,|rb|sbd| › �}n|sv|rvd| › �}nd}td|› d|› d�ƒ}i }tttdœ}t|||ƒ || S )	as  Create a function checking that the function argument is the (unparameterized) typing `member`.

    The function will make sure to check against both the `typing` and `typing_extensions`
    variants as depending on the Python version, the `typing_extensions` variant might be different.
    For instance, on Python 3.9:

    ```pycon
    >>> from typing import Literal as t_Literal
    >>> from typing_extensions import Literal as te_Literal, get_origin

    >>> t_Literal is te_Literal
    False
    >>> get_origin(t_Literal[1])
    typing.Literal
    >>> get_origin(te_Literal[1])
    typing_extensions.Literal
    ```
    zobj is typing.z or obj is typing_extensions.zobj is typing_extensions.ÚFalseú	
    def z&(obj: Any, /) -> bool:
        return ú
    ©r   ÚtypingÚtyping_extensions©Úhasattrr6   r7   Úgetattrr   r   Úexec©r/   r0   Z	in_typingZin_typing_extensionsZ
check_codeÚ	func_codeZlocals_Úglobals_© r?   ú_/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/typing_inspection/typing_objects.pyÚ _compile_identity_check_function<   s(    

ÿþ
rA   c                 C   sÂ   t t| ƒ}t t| ƒ}|rR|rRtt| ƒtt| ƒu r>d| › d�}q‚d| › d| › d�}n0|rh|shd| › d�}n|s~|r~d| › d�}nd}td|› d	| › d
|› d�ƒ}i }tttdœ}t|||ƒ || S )a  Create a function checking that the function is an instance of the typing `member`.

    The function will make sure to check against both the `typing` and `typing_extensions`
    variants as depending on the Python version, the `typing_extensions` variant might be different.
    zisinstance(obj, typing.ú)zisinstance(obj, (typing.z, typing_extensions.z))z"isinstance(obj, typing_extensions.r2   r3   z(obj: Any, /) -> 'TypeIs[z]':
        return r4   r5   r8   r<   r?   r?   r@   Ú"_compile_isinstance_check_functioni   s,    

ÿÿþ
rC   )r   Ú	Annotatedr   z±
Return whether the argument is the [`Annotated`][typing.Annotated] [special form][].

```pycon
>>> is_annotated(Annotated)
True
>>> is_annotated(Annotated[int, ...])
False
```
r   r   zm
Return whether the argument is the [`Any`][typing.Any] [special form][].

```pycon
>>> is_any(Any)
True
```
ÚClassVarr   z¬
Return whether the argument is the [`ClassVar`][typing.ClassVar] [type qualifier][].

```pycon
>>> is_classvar(ClassVar)
True
>>> is_classvar(ClassVar[int])
>>> False
```
ZConcatenater   z»
Return whether the argument is the [`Concatenate`][typing.Concatenate] [special form][].

```pycon
>>> is_concatenate(Concatenate)
True
>>> is_concatenate(Concatenate[int, P])
False
```
r   r   z–
Return whether the argument is the [`Final`][typing.Final] [type qualifier][].

```pycon
>>> is_final(Final)
True
>>> is_final(Final[int])
False
```
Ú
ForwardRefr   zˆ
Return whether the argument is an instance of [`ForwardRef`][typing.ForwardRef].

```pycon
>>> is_forwardref(ForwardRef('T'))
True
```
ÚGenericr   zž
Return whether the argument is the [`Generic`][typing.Generic] [special form][].

```pycon
>>> is_generic(Generic)
True
>>> is_generic(Generic[T])
False
```
ÚLiteralr   z 
Return whether the argument is the [`Literal`][typing.Literal] [special form][].

```pycon
>>> is_literal(Literal)
True
>>> is_literal(Literal["a"])
False
```
Z	ParamSpecr   zŽ
Return whether the argument is an instance of [`ParamSpec`][typing.ParamSpec].

```pycon
>>> P = ParamSpec('P')
>>> is_paramspec(P)
True
```
ÚTypeVarr(   z†
Return whether the argument is an instance of [`TypeVar`][typing.TypeVar].

```pycon
>>> T = TypeVar('T')
>>> is_typevar(T)
True
```
ZTypeVarTupler)   z�
Return whether the argument is an instance of [`TypeVarTuple`][typing.TypeVarTuple].

```pycon
>>> Ts = TypeVarTuple('Ts')
>>> is_typevartuple(Ts)
True
```
ÚUnionr*   a¦  
Return whether the argument is the [`Union`][typing.Union] [special form][].

This function can also be used to check for the [`Optional`][typing.Optional] [special form][],
as at runtime, `Optional[int]` is equivalent to `Union[int, None]`.

```pycon
>>> is_union(Union)
True
>>> is_union(Union[int, str])
False
```

!!! warning
    This does not check for unions using the [new syntax][types-union] (e.g. `int | str`).
)Úobjr1   c                C   s   t | tƒot| tƒot| dƒS )aÃ  Return whether the argument is a named tuple type.

    This includes [`NamedTuple`][typing.NamedTuple] subclasses and classes created from the
    [`collections.namedtuple`][] factory function.

    ```pycon
    >>> class User(NamedTuple):
    ...     name: str
    ...
    >>> is_namedtuple(User)
    True
    >>> City = collections.namedtuple('City', [])
    >>> is_namedtuple(City)
    True
    >>> is_namedtuple(NamedTuple)
    False
    ```
    Ú_fields)Ú
isinstanceÚtypeÚ
issubclassÚtupler9   ©rK   r?   r?   r@   r   *  s    r   r   r   z•
Return whether the argument is the [`LiteralString`][typing.LiteralString] [special form][].

```pycon
>>> is_literalstring(LiteralString)
True
```
ZNeverr   zu
Return whether the argument is the [`Never`][typing.Never] [special form][].

```pycon
>>> is_never(Never)
True
```
ÚNewTyper   c                C   s
   t | dƒS )NÚ__supertype__)r9   rQ   r?   r?   r@   r   \  s    z�
Return whether the argument is a [`NewType`][typing.NewType].

```pycon
>>> UserId = NewType("UserId", int)
>>> is_newtype(UserId)
True
```
Z	NoDefaultr   z„
Return whether the argument is the [`NoDefault`][typing.NoDefault] sentinel object.

```pycon
>>> is_nodefault(NoDefault)
True
```
ZNoExtraItemsr   zy
Return whether the argument is the `NoExtraItems` sentinel object.

```pycon
>>> is_noextraitems(NoExtraItems)
True
```
ÚNoReturnr   zž
Return whether the argument is the [`NoReturn`][typing.NoReturn] [special form][].

```pycon
>>> is_noreturn(NoReturn)
True
>>> is_noreturn(Never)
False
```
ZNotRequiredr   z�
Return whether the argument is the [`NotRequired`][typing.NotRequired] [special form][].

```pycon
>>> is_notrequired(NotRequired)
True
```
ZParamSpecArgsr   zŸ
Return whether the argument is an instance of [`ParamSpecArgs`][typing.ParamSpecArgs].

```pycon
>>> P = ParamSpec('P')
>>> is_paramspecargs(P.args)
True
```
ZParamSpecKwargsr    z§
Return whether the argument is an instance of [`ParamSpecKwargs`][typing.ParamSpecKwargs].

```pycon
>>> P = ParamSpec('P')
>>> is_paramspeckwargs(P.kwargs)
True
```
ZReadOnlyr!   z�
Return whether the argument is the [`ReadOnly`][typing.ReadOnly] [special form][].

```pycon
>>> is_readonly(ReadOnly)
True
```
ZRequiredr"   z�
Return whether the argument is the [`Required`][typing.Required] [special form][].

```pycon
>>> is_required(Required)
True
```
ZSelfr#   zq
Return whether the argument is the [`Self`][typing.Self] [special form][].

```pycon
>>> is_self(Self)
True
```
Z	TypeAliasr$   z…
Return whether the argument is the [`TypeAlias`][typing.TypeAlias] [special form][].

```pycon
>>> is_typealias(TypeAlias)
True
```
Z	TypeGuardr&   z…
Return whether the argument is the [`TypeGuard`][typing.TypeGuard] [special form][].

```pycon
>>> is_typeguard(TypeGuard)
True
```
r	   r'   zy
Return whether the argument is the [`TypeIs`][typing.TypeIs] [special form][].

```pycon
>>> is_typeis(TypeIs)
True
```
r   Ú_is_typealiastype_innerzTypeIs[TypeAliasType]c                C   s   t | ƒtuot| ƒS ©N)rN   r   rU   rQ   r?   r?   r@   r%   ð  s    r%   a'  
Return whether the argument is a [`TypeAliasType`][typing.TypeAliasType] instance.

```pycon
>>> type MyInt = int
>>> is_typealiastype(MyInt)
True
>>> MyStr = TypeAliasType("MyStr", str)
>>> is_typealiastype(MyStr):
True
>>> type MyList[T] = list[T]
>>> is_typealiastype(MyList[int])
False
```
ZUnpackr+   z™
Return whether the argument is the [`Unpack`][typing.Unpack] [special form][].

```pycon
>>> is_unpack(Unpack)
True
>>> is_unpack(Unpack[Ts])
False
```
)r-   é   zTypeIs[deprecated]c                C   s   t | tjtjfƒS rV   )rM   Úwarningsr
   r7   rQ   r?   r?   r@   r     s    r   c                C   s   t | tjƒS rV   )rM   r7   r
   rQ   r?   r?   r@   r     s    a+  
Return whether the argument is a [`deprecated`][warnings.deprecated] instance.

This also includes the [`typing_extensions` backport][typing_extensions.deprecated].

```pycon
>>> is_deprecated(warnings.deprecated('message'))
True
>>> is_deprecated(typing_extensions.deprecated('message'))
True
```
r   )uÚ__doc__Úcollections.abcÚcollectionsÚ
contextlibÚreÚsysr6   rX   Útextwrapr   Útypesr   r   r   r   r7   r   r   r	   r
   Ú__all__Úversion_infoZ	_IS_PY310rA   rC   r   rN   r   r   r   r   r   r   r   r   r   r(   r)   r*   Úboolr   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r&   r'   rU   r%   r+   r   ÚHashableÚabcÚ	AwaitableÚ	CoroutineÚAsyncIterableÚAsyncIteratorÚIterableÚIteratorÚ
ReversibleÚSizedÚ	ContainerÚ
CollectionÚCallableÚAbstractSetÚSetÚ
MutableSetÚMappingÚMutableMappingÚSequenceÚMutableSequenceÚTuplerP   ÚListÚlistÚDequeÚdequeÚsetÚ	FrozenSetÚ	frozensetÚMappingViewÚKeysViewÚ	ItemsViewÚ
ValuesViewÚDictÚdictÚDefaultDictÚdefaultdictÚOrderedDictÚCounterÚChainMapÚ	GeneratorÚAsyncGeneratorÚTypeÚPatternÚMatchÚContextManagerÚAbstractContextManagerÚAsyncContextManagerÚAbstractAsyncContextManagerr   Ú__annotations__ÚitemsÚaliasÚtargetr:   Ú_nameZte_aliasr?   r?   r?   r@   Ú<module>   s  $- 


	













	
	

	
	

	




	
	

	
	
	


























×0