Viewing File: /opt/hc_python/lib/python3.12/site-packages/sqlalchemy/util/__pycache__/typing.cpython-312.pyc

�

a��g�Q��$�ddlmZddlZddlmZddlmZddlZddl	Z	ddl
Z
ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZddl
mZddlmZ	ddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&dd lm'Z'dd!lm(Z(dd"lm)Z)dd#lm*Z*dd$lm+Z+dd%lm,Z,dd&lm-Z-dd'lm.Z.dd(lm/Z/dd)lm0Z0dd*lm1Z1ed+e�,�Z2ed-�Z3ed.d�/�Z4ed0d�1�Z5ed2�Z6ed3d�/�Z7ejpre9e
jNe'g�Z:n	e9e'g�Z:ejvrdd4l<m=Z=ne>d�Z=ed5�Z?eeee@eee0d6fZAGd7�d8e*�ZBGd9�d:e*e2�ZCGd;�d<e*e3e7f�ZDe'd=ZEdd>dd?�															dld@�ZF				dmdA�ZG						dndB�ZHdddC�									dodD�ZIddE�							dpdF�ZJdqdG�ZKdrdH�ZLdsdI�ZMdtdJ�ZNdudK�ZOdvdL�ZPdwdM�ZQdxdN�ZRdydO�ZS		dz							d{dP�ZTed|dQ��ZUed}dR��ZUe				dmdS��ZU				dmdT�ZUe						d~dU��ZVe						ddV��ZV						d�dW�ZVd�dX�ZWdtdY�ZXd�dZ�ZY						d�d[�ZZdd\�							d�d]�Z[d�d^�Z\Gd_�d`e*�Z]edae]�,�Z^Gdb�dcee^�Z_edde]d�e�Z`Gdf�dgee`�Zaedheedief�,�ZbGdj�dkeeb�Zcy)��)�annotationsN)�deque)�Any)�Callable)�cast)�Dict)�
ForwardRef)�Generic)�Iterable)�Mapping)�NewType)�NoReturn)�Optional)�overload)�Set)�Tuple)�Type)�
TYPE_CHECKING)�TypeVar)�Union�)�compatT)�	Annotated)�Concatenate)�dataclass_transform)�Final)�final)�get_args)�
get_origin)�Literal)�NotRequired)�	ParamSpec)�Protocol)�
SupportsIndex)�	TypeAlias)�	TypedDict)�	TypeGuard)�Self)�
TypeAliasType)�Never�_T)�bound�_KT�_KT_co)�	covariant�
_KT_contra)�
contravariant�_VT�_VT_co)�NoneType�NonezGenericProtocol[Any]c��eZdZUdZded<y)�ArgsTypeProtocolz_protocol for types that have ``__args__``

    there's no public interface for this AFAIK

    �Tuple[_AnnotationScanType, ...]�__args__N��__name__�
__module__�__qualname__�__doc__�__annotations__���G/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/util/typing.pyr7r7Zs���.�-rAr7c�&�eZdZUdZded<ded<y)�GenericProtocolzXprotocol for generic types.

    this since Python.typing _GenericAlias is private

    r8r9�Type[_T]�
__origin__Nr:r@rArBrDrDds���.�-��rArDc��eZdZdd�Zdd�Zy)�SupportsKeysAndGetItemc��y�Nr@)�selfs rB�keyszSupportsKeysAndGetItem.keysys��SrAc��yrJr@)rK�_SupportsKeysAndGetItem__ks  rB�__getitem__z"SupportsKeysAndGetItem.__getitem__{s��srAN)�returnz
Iterable[_KT])rNr-rPr3)r;r<r=rLrOr@rArBrHrHxs��(�2rArH�*F��str_cleanup_fn�include_generic�
_already_seenc�l�������|}t|�r|j}t|t�r�r	�|��}t	|�����}�rht|�r]t
|�sR��
t��|�vr|S�j|�t������fd�|jD��}t||�S|S)a;Resolve annotations that may be string based into real objects.

    This is particularly important if a module defines "from __future__ import
    annotations", as everything inside of __annotations__ is a string. We want
    to at least have generic containers like ``Mapped``, ``Union``, ``List``,
    etc.

    ��locals_�in_classc
3�B�K�|]}t�|����������y�w)rRN)�de_stringify_annotation)�.0�elemrU�clsrTrX�originating_modulerSs  ������rB�	<genexpr>z*de_stringify_annotation.<locals>.<genexpr>�s<�����
�,��
$���"��-� /�+�
�
�,�s�)�
is_fwd_ref�__forward_arg__�
isinstance�str�eval_expression�
is_generic�
is_literal�set�add�tupler9�_copy_generic_annotation_with)	r^�
annotationr_rXrSrTrU�original_annotation�elementss	` `````  rBr[r[�s����.%���*���/�/�
��*�c�"��'�
�4F�G�J�$��*�G�c�
�
�
	��z�"��:�&�� ��E�M���&�
'�&����j�)��
�
�#�+�+�
�
��-�Z��B�B��rAc���t|�r�t|�tttt
jt
jt
jt
jt
jfvrttjdt|��sUt|�jtt!|�D�cgc]}t#|t$�rt'|�n|��!c}��S|Scc}w)zfCorrect dict['x', 'y'] into dict[ForwardRef('x'), ForwardRef('y')]
    and similar for list, set

    z3typing.(?:Dict|List|Set|.*Mapping|.*Sequence|.*Set))rfr�dictrh�list�collections_abc�
MutableSet�MutableMapping�MutableSequencer�Sequence�re�match�repr�__class_getitem__rjrrcrdr	)�type_r]s  rB�fixup_container_fwd_refsr|�s���	�5���u������&�&��*�*��+�+��#�#��$�$�	
�

����A�4��;�
�
�%� �2�2��!)���� /��)3�4��(=�J�t�$�4�G� /��
�
�	
��L��
s�8$C)c�Z�t|d�r|j|�S|j|S)N�	copy_with)�hasattrr~rF)rlrns  rBrkrk�s2���z�;�'��#�#�H�-�-��$�$�X�.�.rArWc��	tj|j}	|�Qt|j�}|j
|j|�|j|�t|||�}|St|||�}	|S#t$r}t	d|�d|���|�d}~wwxYw#t$r}t	d|���|�d}~wwxYw)N�Module z9 isn't present in sys.modules; can't evaluate expression z"Could not de-stringify annotation )�sys�modules�__dict__�KeyError�	NameErrorrp�
setdefaultr;�update�eval�	Exception)	�
expression�module_namerXrY�base_globals�ke�
cls_namespacerl�errs	         rBrere�s����'*�{�{�;�'?�'H�'H����� ��!2�!2�3�M��$�$�X�%6�%6��A�

� � ��.��j�-��A�J���
�j�,��@�J����1����k�]�##�#-�,�
0�
��	����&���0���?�
��	���s5�B�AB&�3
B&�	B#�B�B#�&	C�/B>�>C�rXc�J�d|vrt|||��S	tj|j}	||S#t$r}td|�d|���|�d}~wwxYw#t$r?}	tj|cYd}~S#t$rYnwxYwtd|�d|���|�d}~wwxYw)N�.r�r�z2 isn't present in sys.modules; can't resolve name zCould not locate name z in module )rer�r�r�r�r��builtins)�namer�rXr�r�s     rB�eval_name_onlyr�!s����d�{��t�[�'�B�B��'*�{�{�;�'?�'H�'H����D�!�!������k�]�#� �6�
#�
��	�����	�	��$�$�T�*�*���	��	���$�T�F�+�k�]�C�
��	��	�sJ�7�A�	A�A�A�	B"�$A<�6B"�<	B�B�B�B�B"c�X�	t||�}t|d|�S#t$r|cYSwxYw)Nr;)r��getattrr�)r�r��objs   rB�resolve_name_to_real_class_namer�Cs:��.��T�;�/���s�J��-�-�������s��)�)c�0�|duxrt|�tuSrJ)rr�r{s rB�	is_pep593r�Ls�����?��E�!2�i�!?�?rAc�h�t|tj�xrt|ttf�SrJ)rcrrrrd�bytes)r�s rB�is_non_string_iterabler�Ps1���c�?�3�3�4��Z��c�5�\�>�:�rAc�$�t|�tvSrJ)r�
LITERAL_TYPESr�s rBrgrgVs���e��
�-�-rAc��t|d�S)N�
__supertype__�rr�s rB�
is_newtyper�Zs���5�/�*�*rAc�6�t|d�xrt|d�S)Nr9rFr�r�s rBrfrfbs���5�*�%�F�'�%��*F�FrAc�"�t|t�SrJ)rcr)r�s rB�	is_pep695r�fs���e�]�+�+rAc�d�|j}t|�r|j}t|�r�|SrJ)r�r�)r{�
super_types  rB�flatten_newtyper�js0���$�$�J�
�Z�
 ��-�-�
��Z�
 ��rAc�:���t����fd���|�}t|t�rot�}t|�}|rV|j	�}t|t�r|j|�n!|j
|tthvrdn|�|r�V|S|hS)z�Extracts the value from a TypeAliasType, recursively exploring unions
    and inner TypeAliasType to flatten them into a single set.

    Forward references are not evaluated, so no recursive exploration happens
    into them.
    c����|�vr|S�j|�t|�s|S|j}t|�s|S|jD�cgc]
}�|���c}Scc}wrJ)rir��	__value__�is_unionr9)r{�value�t�_seen�recursive_values   ��rBr�z&pep695_values.<locals>.recursive_valuezs`����E�>��L�
�	�	�%������L���������L�,1�N�N�;�N�q���"�N�;�;��;s�
AN)	rhrcrqr�popleft�extendrir4�NoneFwd)r{�res�types�stackr�r�r�s     @@rB�
pep695_valuesr�qs����
�E�E�<��%�
 �C��#�t������c�
����
�
��A��!�T�"����Q���	�	�!��'�':�":�$��B�����u�rAc����rt|t�ryt|t�ry|r)t|�rt	�fd�|j
D��Sy)NTc3�:�K�|]}t|d������y�w)T)�check_for_plain_stringN)ra)r\�argr�s  �rBr`zis_fwd_ref.<locals>.<genexpr>�s/�����
�&��
��T�2H�
�
�&�s�F)rcrdr	rf�anyr9)r{�
check_genericr�s  `rBrara�sP���
�*�U�C�"8��	�E�:�	&��	�:�e�,��
��~�~�	
�
�	
�rAc��yrJr@r�s rB�de_optionalize_union_typesr��s��36rAc��yrJr@r�s rBr�r��s��?BrAc��yrJr@r�s rBr�r�����rAc��t|�rt|d�St|�r�t|�r�tj
rt
|j�}n{t|g�}t
�}|rR|j�}|jD]0}t|�r|j|�� |j|��2|r�R|jd�|jt�|jt�t|�S|S)z�Given a type, filter out ``Union`` types that include ``NoneType``
    to not include the ``NoneType``.

    Contains extra logic to work on non-flattened unions, unions that contain
    ``None`` (seen in py38, 37)

    FN)ra�#_de_optionalize_fwd_ref_union_typesr��
includes_noner�py39rhr9rr��appendri�discardr4r��make_union_type)r{�typ�stack_of_unions�u_typr]s     rBr�r��s����%��2�5�%�@�@�	�%��]�5�1��;�;��e�n�n�%�C�$�U�G�n�O��%�C�!�'�/�/�1��!�N�N�D���~�'�.�.�t�4�����
�	+�"�
�K�K������H�����G����$�$��rAc��yrJr@�r{�return_has_nones  rBr�r��s��rAc��yrJr@r�s  rBr�r��r�rAc��|j}tjd|�}|�r^|jd�j	d�d}|dk(r|rdSt|jd��S|dk(�rd	|jd�vr�g}g}d
}|jd�D]r}|d	k(r|dz
}nT|dk(r|dz}nI|d
k(rD|dk(r?|j
d
j|�j��|j��b|j
|��tn%tjd|jd��}|D�	cgc]}	|	dk7s�	t|	���}
}	|rt|�t|
�k7S|
rt|
�StS|rdS|Stjd|�}d|v}|r|S|r+djd�|D��}
|
rt|
�StS|Scc}	w)z�return the non-optional type for Optional[], Union[None, ...], x|None,
    etc. without de-stringifying forward refs.

    unfortunately this seems to require lots of hardcoded heuristics

    z^(.+?)\[(.+)\]$rr����rT�r�[r�]�,�z,\s*r5Fz\s*\|\s*�|c3�,K�|]}|dk7s�	|���y�w)r5Nr@)r\�ps  rBr`z6_de_optionalize_fwd_ref_union_types.<locals>.<genexpr>s����B�{�!�a�6�k�A�{�s�
�)
rbrwrx�group�splitr	r��join�strip�clear�lenr�r*)r{r�rl�mm�g1rn�current�ignore_comma�charr]�parts�pipe_tokens�has_none�anno_strs              rBr�r��s����&�&�J�	���$�j�	1�B�	�
�X�X�a�[�
�
�s�
#�B�
'��
���*�4�G�
�2�8�8�A�;�0G�G�
�7�]��b�h�h�q�k�!�&(��%'�� ���H�H�Q�K�D��s�{�$��)�����$��)��%��*�t�s�{� �������(8�(>�(>�(@�A��
�
�� ��N�N�4�(�(��8�8�G�R�X�X�a�[�9��2:�M�(�$�d�f�n�Z��%�(�E�M���8�}��E�
�2�2�27���.�B�U�B�+�5�6��6��(�(�;�
�3�K���$�H������8�8�B�{�B�B��'/�z�(�#�:�U�:��L��!Ns�;
G�
Gc�,�tj|�S)zMake a Union type.)rrO)r�s rBr�r�#s�����U�#�#rAc�j�t|�rt|d�St|�rtd�t	|�D��St|�rt
t	|�d�St|�rtd�t|�D��St|�rt
|j�S|ttdfvS)a.Returns if the type annotation ``type_`` allows ``None``.

    This function supports:
    * forward refs
    * unions
    * pep593 - Annotated
    * pep695 - TypeAliasType (does not support looking into
    fw reference of other pep695)
    * NewType
    * plain types like ``int``, ``None``, etc
    Tc3�2K�|]}t|����y�wrJ�r��r\r�s  rBr`z includes_none.<locals>.<genexpr>7s����=�_��=��#�_���rc3�2K�|]}t|����y�wrJr�r�s  rBr`z includes_none.<locals>.<genexpr>;s����B�-A��=��#�-A�r�N)
rar�r�r�rr�r�r�r�r�r�r�r4r�s rBr�r�(s����%��2�5�$�?�?�����=�X�e�_�=�=�=�����X�e�_�Q�/�0�0�����B�]�5�-A�B�B�B��%���U�0�0�1�1��W�h��-�-�-rAc��t|dd�S)Nr�	UnionType)�is_origin_ofr�s rBr�r�As����w��4�4rAc�Z�t|�}|�yt|t�xrt||�S)z[return True if the given type has an __origin__ that shares a base
    with the given classF)rrc�type�
issubclass)r{�	class_obj�origins   rB�is_origin_of_clsr�Es/����
�F�
�~���f�d�#�E�
�6�9�(E�ErA)�modulec�~�t|�}|�yt|�|vxr!|duxs|jj|�S)z\return True if the given type has an __origin__ with the given name
    and optional module.NF)r�_get_type_namer<�
startswith)r{r��namesr�s    rBr�r�RsJ����
�F�
�~���&�!�U�*���$��>�&�+�+�6�6�v�>�rAc�v�tjr|jSt|dd�}|�
t|dd�}|S)Nr;�_name)r�py310r;r�)r{�typ_names  rBrras:��
�|�|��~�~���5�*�d�3�����u�g�t�4�H��rAc�$�eZdZdd�Zdd�Zdd�Zy)�DescriptorProtoc��yrJr@�rK�instance�owners   rB�__get__zDescriptorProto.__get__ms��CrAc��yrJr@�rKrr�s   rB�__set__zDescriptorProto.__set__os��#rAc��yrJr@�rKrs  rB�
__delete__zDescriptorProto.__delete__qs��rAN)r�objectrrrPr)rrr�rrPr5�rrrPr5)r;r<r=r
rrr@rArBrrls��?�=�4rAr�_DESCc�.�eZdZdZer
dd�Zdd�Zdd�Zyy)	�DescriptorReferencea�a descriptor that refers to a descriptor.

    used for cases where we need to have an instance variable referring to an
    object that is itself a descriptor, which typically confuses typing tools
    as they don't know when they should use ``__get__`` or not when referring
    to the descriptor assignment as an instance variable. See
    sqlalchemy.orm.interfaces.PropComparator.prop

    c��yrJr@r
s   rBr
zDescriptorReference.__get__����#rAc��yrJr@rs   rBrzDescriptorReference.__set__����rAc��yrJr@rs  rBrzDescriptorReference.__delete__����SrAN)rrrrrPr)rrr�rrPr5r�r;r<r=r>rr
rrr@rArBrrws����E�C�8�
rAr�_DESC_co)r,r/c�.�eZdZdZer
dd�Zdd�Zdd�Zyy)	�RODescriptorReferencez�a descriptor that refers to a descriptor.

    same as :class:`.DescriptorReference` but is read-only, so that subclasses
    can define a subtype as the generically contained element

    c��yrJr@r
s   rBr
zRODescriptorReference.__get__�s��SrAc��yrJr@rs   rBrzRODescriptorReference.__set__�rrAc��yrJr@rs  rBrz RODescriptorReference.__delete__�s��rAN)rrrrrPr )rrr�rrPr)rrrPrrr@rArBr"r"�s����H�E�<�
rAr"�_FN.c�.�eZdZdZer
dd�Zdd�Zdd�Zyy)	�CallableReferencez�a descriptor that refers to a callable.

    works around mypy's limitation of not allowing callables assigned
    as instance variables


    c��yrJr@r
s   rBr
zCallableReference.__get__�rrAc��yrJr@rs   rBrzCallableReference.__set__�s��crAc��yrJr@rs  rBrzCallableReference.__delete__�rrAN)rrrrrPr&)rrr�r&rPr5rrr@rArBr(r(�s����C�A�8�
rAr()r^�	Type[Any]rl�_AnnotationScanTyper_rdrXzMapping[str, Any]rSz#Optional[Callable[[str, str], str]]rT�boolrUzOptional[Set[Any]]rPr,)r{r-rPr-)rlzGenericProtocol[_T]rnr8rPrE)
r�rdr�rdrX�Optional[Mapping[str, Any]]rYzOptional[Type[Any]]rPr)r�rdr�rdrXr/rPr)r�rdr�rdrPrd)r{z
Optional[Any]rPr.)r�rrPzTypeGuard[Iterable[Any]])r{rrPr.)r{zOptional[_AnnotationScanType]rPzTypeGuard[NewType])r{r-rPzTypeGuard[GenericProtocol[Any]])r{r-rPzTypeGuard[TypeAliasType])r{r
rPr,)r{r-rPzSet[Any])FF)r{r-r�r.r�r.rPzTypeGuard[ForwardRef])r{rdrPrd)r{r,rPr,)r{r	r�z
Literal[True]rPr.)r{r	r�zLiteral[False]rPr-)r{r	r�r.rPz Union[_AnnotationScanType, bool])r�r-rPr,)r{rrPzTypeGuard[ArgsTypeProtocol])r{rr�z'Union[Tuple[Type[Any], ...], Type[Any]]rPr.)r{rrrdr�z
Optional[str]rPr.)r{r,rPrd)d�
__future__rr��collectionsr�collections.abc�abcrrrwr��typingrrrrr	r
rrr
rrrrrrrrrr�r�typing_extensionsrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r-r.r0r2r3�py38�	frozensetr�rr�r4r�r�rdr-r7rDrH�_LiteralStarr[r|rkrer�r�r�r�rgr�rfr�r�r�rar�r�r�r�r�r�r�rrrrr r"r&r(r@rArB�<module>r9s���#���)�	�
�
���������������� �����8�<��1�0�6�:�4�<�8�6�@�8�8�8�.�@�0��T����
�e�n��	��T�	*��
�\��
6�
�
�e�n��	��T�	*��	�;�;��v�~�~�w�7�8�M��w�i�(�M�
�<�<�+��D�z�H�
�V�
�����I�s�J���8N�N���
.�x�.��h�r�l��(3�X�c�6�k�2�3��s�|��;?�!�(,�D�	�D�#�D��D��	D�8�
D��D�&�D��D�N&��&��&�R/�#�/�/N�/�
�/�,0�$(�!��!��!�)�	!�
"�!�	�
!�P,0�	�

����)�	�
	��D.�@��.�+�G�,��"�N �#(������!���	�(
�6�
�6�
�B�
�B�
������
��
&��&��&�R
����(5��	��
��

����(6����
��
3��3�(,�3�%�3�l$�
.�25�
F��
F�B�
F�	�
F�6:������%2��	���5�h�5�	���/��9�'�%�.�9�(�:�_��E��=�G�H�-�=�"�e�8�H�S�#�X�$6�7�8��9����9rA
Back to Directory File Manager