� k\�gEG��v�UdZddlmZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd lm Z dd lm Z dd lm Z ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZer ddlmZddlmZe e efZ!ej"Z#de$d<Gd�d e��Z%Gd!�d"e%��Z&Gd#�d$e&��Z'Gd%�d&e%��Z(iZ)d'e$d(<ed)d �*��Z*dKd/�Z+ dLd0d0dd1�dMd:�Z,e dLdNd>���Z-e dLdOd?���Z- dLdPdA�Z-dQdB�Z.dRdG�Z/dSdJ�Z0dS)Ta*The :class:`.Annotated` class and related routines; creates hash-equivalent copies of SQL constructs which contain context-specific markers and associations. Note that the :class:`.Annotated` concept as implemented in this module is not related in any way to the pep-593 concept of "Annotated". �)� annotationsN)�Any)�Callable)�cast)�Dict)� FrozenSet)�Mapping)�Optional)�overload)�Sequence)�Tuple)�Type)� TYPE_CHECKING)�TypeVar�)� operators)� HasCacheKey)�anon_map)�ExternallyTraversible)�InternalTraversal�)�util)�Literal)�Self)�_EntityNamespace)�_TraverseInternalsType�util.immutabledict[str, Any]�EMPTY_ANNOTATIONSc��eZdZUdZeZded<ded<ded<dd �Ze ddd���Z e ddd���Z dd d�Z e j d!d���Z d"d�Z dS)#�SupportsAnnotations�r� _annotationsz*util.generic_fn_descriptor[FrozenSet[Any]]� proxy_set�bool� _is_immutable�values�_AnnotationDict�returnrc��t����N��NotImplementedError��selfr&s �i/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sqlalchemy/sql/annotation.py� _annotatezSupportsAnnotations._annotate>s��!�#�#�#�.� Literal[None]�clonec��dSr*r!�r.r&r3s r/� _deannotatezSupportsAnnotations._deannotateA� �� �sr1� Sequence[str]c��dSr*r!r5s r/r6zSupportsAnnotations._deannotateH� �� "�cr1NF�Optional[Sequence[str]]c��t���r*r+r5s r/r6zSupportsAnnotations._deannotateOs�� "�#�#�#r1�Tuple[Any, ...]c�H�t��}|�|��Sr*)r�_gen_annotations_cache_key)r.� anon_map_s r/�_annotations_cache_keyz*SupportsAnnotations._annotations_cache_keyVs���J�J� ��.�.�y�9�9�9r1rc�|���dt�fd��fd�t�j��D��D����fS)Nr"c3�|�K�|]6\}}|t|t��r|��g��n|fV��7dSr*)� isinstancer�_gen_cache_key)�.0�key�valuers �r/� <genexpr>zASupportsAnnotations._gen_annotations_cache_key.<locals>.<genexpr>asn����� � ��C���&�e�[�9�9�#��,�,�X�r�:�:�:�"� � � � � � � r1c�.��g|]}|�j|f��Sr!)r")rFrGr.s �r/� <listcomp>zBSupportsAnnotations._gen_annotations_cache_key.<locals>.<listcomp>js6���#�#�#���$�+�C�0�1�#�#�#r1)�tuple�sortedr")r.rs``r/r?z.SupportsAnnotations._gen_annotations_cache_key\st���� � � � � � �#�#�#�#�%�d�&7�8�8�#�#�#� � � � � � � r1�r&r'r(r�..�r&r2r3r$r(r�r&r8r3r$r(r �NF�r&r;r3r$r(r )r(r=)rrr(r=)�__name__� __module__� __qualname__� __slots__rr"�__annotations__r0r r6r�memoized_propertyrAr?r!r1r/r r 5s ��������I�1B�L�B�B�B�B�9�9�9�9�����$�$�$�$��!$�������X�� �!$��"�"�"�"��X�"�+/��$�$�$�$�$� ��:�:�:���:�  � � � � � r1r c��eZdZUdZded<erejdd���Zdd �Z dd �Z e ddd���Z e ddd���Z ddd�Z dS)�SupportsWrappingAnnotationsr!z*Callable[..., SupportsWrappingAnnotations]� _constructorr(rc��dSr*r!�r.s r/�entity_namespacez,SupportsWrappingAnnotations.entity_namespaceys��8;�r1r&r'rc�8�t�||��S)�greturn a copy of this ClauseElement with annotations updated by the given dictionary. �� Annotated�_as_annotated_instancer-s r/r0z%SupportsWrappingAnnotations._annotate|��� �/�/��f�=�=�=r1c�8�t�||��S)�hreturn a copy of this ClauseElement with annotations replaced by the given dictionary. rbr-s r/�_with_annotationsz-SupportsWrappingAnnotations._with_annotations�rer1.r2r3r$c��dSr*r!r5s r/r6z'SupportsWrappingAnnotations._deannotate�r7r1r8r c��dSr*r!r5s r/r6z'SupportsWrappingAnnotations._deannotate�r:r1NFr;c�6�|r|���}|S|S)��return a copy of this :class:`_expression.ClauseElement` with annotations removed. :param values: optional tuple of individual values to remove. )�_clone)r.r&r3�ss r/r6z'SupportsWrappingAnnotations._deannotate�s#�� � �� � � � �A��H��Kr1�r(rrNrOrPrQrRrS) rTrUrVrWrXrr�ro_non_memoized_propertyr_r0rhr r6r!r1r/r[r[rs���������I�<�<�<�<��<� � &�;�;�;� '� &�;�>�>�>�>�>�>�>�>��!$�������X�� �!$��"�"�"�"��X�"�+/��������r1r[c��eZdZUejsdZdejfgZde d<dd �Z dd �Z e ddd���Z e ddd���Z ddd�Z dS)�SupportsCloneAnnotationsr!r"r�%_clone_annotations_traverse_internalsr&r'r(rc���|���}|j�|��|_|j�dd��|j�dd��|S)rarAN�_generate_cache_key)rmr"�union�__dict__�pop�r.r&�news r/r0z"SupportsCloneAnnotations._annotate�sa�� �k�k�m�m���+�1�1�&�9�9��� � ���1�4�8�8�8� � ���.��5�5�5�� r1c���|���}tj|��|_|j�dd��|j�dd��|S)rgrANru)rmr� immutabledictr"rwrxrys r/rhz*SupportsCloneAnnotations._with_annotations�s[�� �k�k�m�m���-�f�5�5��� � ���1�4�8�8�8� � ���.��5�5�5�� r1.r2r3r$c��dSr*r!r5s r/r6z$SupportsCloneAnnotations._deannotate�r7r1r8r c��dSr*r!r5s r/r6z$SupportsCloneAnnotations._deannotate�r:r1NFr;c��|s|jrI|���}tj��|_|j�dd��|S|S)rlrAN)r"rmrr|rwrx)r.r&r3rzs r/r6z$SupportsCloneAnnotations._deannotate�sY�� � �D�%� ��+�+�-�-�C�#�1�3�3�C� � �L� � �5�t� <� <� <��J��Kr1rNrOrPrQrRrS)rTrUrV�typingrrWr�dp_annotations_keyrsrXr0rhr r6r!r1r/rrrr�s�������� � ��� � �*�=�>�E�)����� � � � � � � � ��!$�������X�� �!$��"�"�"�"��X�"�+/��������r1rrc�&�eZdZUdZdZed/d���Zd ed <ded <d ed <d0d�Zd1d�Z d2d�Z d2d�Z e d3d4d���Z e d3d5d���Z d6d7d"�Z ejsd8d%�Zed&���Zd9d'�Zd:d)�Zd;d*�Zd<d,�Zejd=d.���ZdS)>rcaJclones a SupportsAnnotations and applies an 'annotations' dictionary. Unlike regular clones, this clone also mimics __hash__() and __eq__() of the original element so that it takes its place in hashed collections. A reference to the original element is maintained, for the important reason of keeping its hash value current. When GC'ed, the hash value may be reused, causing conflicts. .. note:: The rationale for Annotated producing a brand new class, rather than placing the functionality directly within ClauseElement, is **performance**. The __hash__() method is absent on plain ClauseElement which leads to significantly reduced function call overhead, as the use of sets and dictionaries against ClauseElement objects is prevalent, but most are not "annotated". F�elementr[r&r'r(c�� t|j}n%#t$rt|j|��}YnwxYw|||��Sr*)�annotated_classes� __class__�KeyError�_new_annotation_type)�clsr�r&s r/rdz Annotated._as_annotated_instance sY�� ?�#�G�$5�6�C�C��� ?� ?� ?�&�w�'8�#�>�>�C�C�C� ?�����s�7�F�#�#�#s ��7�7rr"�_Annotated__element�int�_hashr�� Type[Self]�argsrrc�6�t�|��Sr*)�object�__new__)r�r�s r/r�zAnnotated.__new__s���~�~�c�"�"�"r1c��|j���|_|j�dd��|j�dd��||_t j|��|_t|��|_dS�NrAru) rw�copyrxr�rr|r"�hashr�)r.r�r&s r/�__init__zAnnotated.__init__sw�� �(�-�-�/�/�� � � ���2�D�9�9�9� � ���/��6�6�6� ��� �.�v�6�6����'�]�]�� � � r1c�d�|j�|��}|�|��}|Sr*)r"rvrh)r.r&�_valuesrzs r/r0zAnnotated._annotate(s0���#�)�)�&�1�1���$�$�W�-�-��� r1c��|j�|j��}|j���|_|j�dd��|j�dd��t j|��|_|Sr�)r�r�rwr�rxrr|r"r5s r/rhzAnnotated._with_annotations-sx����&�&�t�~�6�6����+�+�-�-��� ����3�T�:�:�:� ����0�$�7�7�7�!�/��7�7���� r1.r2r3r$c��dSr*r!r5s r/r6zAnnotated._deannotate5r7r1r8c��dSr*r!r5s r/r6zAnnotated._deannotate<s �� �Cr1NTr;r c�����|jS|�tj�fd�|j���D������S)Nc�$��i|] \}}|�v� ||�� Sr!r!)rFrGrHr&s �r/� <dictcomp>z)Annotated._deannotate.<locals>.<dictcomp>Ms4������&�C���f�,�,��U�,�,�,r1)r�rhrr|r"�itemsr5s ` r/r6zAnnotated._deannotateCso��� �>��>� !��)�)��"�����*.�*;�*A�*A�*C�*C�������� r1�visitor�kwc �4�|jjj||fi|��Sr*)r�r��_compiler_dispatch)r.r�r�s r/r�zAnnotated._compiler_dispatchWs0��>�4�>�+�>��g���!#��� r1c��|jjSr*)r�r\r^s r/r\zAnnotated._constructor\s ���>�.� .r1c ��|jjdi|��}||jur|S|j�|j��|�||j��S)Nr!)r�rmrw�updater�r")r.r�r3s r/rmzAnnotated._clone`s_��%���%�+�+��+�+�� �D�N� "� "��K� �N� !� !�$�-� 0� 0� 0��>�>�%��):�;�;� ;r1�'Tuple[Type[Annotated], Tuple[Any, ...]]c�,�|j|j|jffSr*)r�r�r"r^s r/� __reduce__zAnnotated.__reduce__ks���~����0A�B�B�Br1c��|jSr*)r�r^s r/�__hash__zAnnotated.__hash__ns ���z�r1�otherc��|jr |jj�||��St |��t |��kSr*)�_is_column_operatorsr�r��__eq__r�)r.r�s r/r�zAnnotated.__eq__qs?�� � $� -��>�+�2�2�4��?�?� ?���;�;�$�t�*�*�,� ,r1rc�v�d|jvr%tt|jd��jS|jjS)Nr_)r"rr[r_r�r^s r/r_zAnnotated.entity_namespacewsC�� ��!2� 2� 2��+��!�"4�5���� � �>�2� 2r1)r�r[r&r'r(rc)r�r�r�rr(r)r�r[r&r'rNrOrP)r&r8r3r$r(rc)NTrS)r�rr�rr(r)r�rr(r)r(r�)r(r�)r�rr(r$ro)rTrUrV�__doc__r�� classmethodrdrXr�r�r0rhr r6r�rr��propertyr\rmr�r�r�rrpr_r!r1r/rcrc�s����������&!���$�$�$��[�$�/�.�.�.�*�*�*�*��J�J�J�#�#�#�#�#�#�#�#����� �����!$�������X�� �!$�������X��+/�������$ � � /� � � � � � /� /� �� /� <� <� <� <�C�C�C�C�����-�-�-�-�  �"�3�3�3�#�"�3�3�3r1rcz8Dict[Type[SupportsWrappingAnnotations], Type[Annotated]]r��_SA)�bound� to_annotaterr'r(c�L� |j}||��S#t$r|cYSwxYwr*)r0�AttributeError)r�rr0s r/�_safe_annotater��sL��&��)� ��y��%�%�%�� �������� ���s �� #�#F)�detect_subquery_cols�ind_cols_on_fromclause�annotate_callabler��exclude�'Optional[Sequence[SupportsAnnotations]]r�r$r�r��OOptional[Callable[[SupportsAnnotations, _AnnotationDict], SupportsAnnotations]]c�t��������i�d�������fd� �|�tt�|����}d�|S) z�Deep copy the given ClauseElement, annotating each element with the given annotations dictionary. Elements within the exclude collection will be cloned but not annotated. �elemr r�rr(c���� |d<t|��}|�vr�|S� r:t|d��r*|j�� ��r|jdd�i|��}nH�|jkr;� r|jr|jdd�i|��}n|}�r �|���}nt|���}n|}|��� ���|�|<|S)Nr�r#r3)r3r�r!) �id�hasattrr#� intersectionrmr"r%r��_copy_internals) r�r��id_�newelemr�r�rr3� cloned_idsr�r�r�s �������r/r3z_deep_annotate.<locals>.clone�s/���&:�� !�"���h�h�� �*� � ��c�?� "� � ���k�*�*� ���+�+�G�4�4� � "�d�k�4�4��4��4�4�G�G� �D�-� -� -�#� #��(:� #�)�d�k�<�<��<��<�<� � �"� � � C�+�+�K��E�E���(��k�B�B����G�����0F� � � � �"� �3���r1N�r�r r�rr(r �rr�)r�rr�r�r�r�r3r�s `````@@r/�_deep_annotater��sv���������*24�J�'�'�'�'�'�'�'�'�'�'�'�'�R���s�E�E�'�N�N�+�+�� �E� �Nr1r2r&r;c��dSr*r!�r�r&s r/�_deep_deannotater��s ���Cr1c��dSr*r!r�s r/r�r��s �� �#r1� Optional[_SA]c�d����i�d���fd� �|�tt�|����}d�|S) z2Deep copy the given element, removing annotations.r�r r�rr(c����rt|��}n|}|�vr4|��d���}|�����|�|<|S�|S)NT)r&r3)r3)r�r6r�)r�r�rGr�r3�clonedr&s ���r/r3z_deep_deannotate.<locals>.clone�so��� � ��T�(�(�C�C��C� �f� � ��&�&�f�D�&�A�A�G� � #� #�%� #� 0� 0� 0�!�F�3�K��N��#�;� r1Nr�r�)r�r&r3r�s `@@r/r�r��s]����� .0�F� � � � � � � � ����s�E�E�'�N�N�+�+�� �E� �Nr1c�X�|�|��}|���|S)a Annotate the given ClauseElement and copy its internals so that internal objects refer to the new annotated object. Basically used to apply a "don't traverse" annotation to a selectable, without digging throughout the whole structure wasting time. )r0r�)r�rs r/�_shallow_annotater�s.����� �,�,�G� ������ �Nr1r��!Type[SupportsWrappingAnnotations]�base_cls�Type[Annotated]c��t|t��r|S|tvr t|S|jD]}|tvrt|}n�t t tt d|jz||fi����xt|<}|t��d|jz<d|j vr*t|j ��dtj fgz|_ nD|j �dd��r)t|j ��dtj fgz|_ |j �dd��rd|_nd|j vr|j d|_t|t j��|_|S)z[Generates a new class that subclasses Annotated and proxies a given element type. z Annotated%s�_traverse_internalsr"� inherit_cacheFT)� issubclassrcr��__mro__rr�typerT�globalsrw�listr�rr��getr�r�ColumnOperatorsr�)r�r��super_�anno_clss r/r�r�s����#�y�!�!�&�� � �!� !� !� ��%�%��+���� �&� &� &�(��0�H� �E� '�)-� �Y�� �]�S�\� )�H�c�?�B�?�?�)�)���c��X�/7�G�I�I�m�c�l�*�+��� �,�,�'+�C�,C�'D�'D� �.�A� B�H �( ��$�$� �� � �/�5� 1� 1� �'+�C�,C�'D�'D� �.�A� B�H �( ��$�  �|�����/�/�?�!%���� �C�L� (� (�!$��o�!>���$.�s�I�4M�$N�$N�H�!� �Or1�target_hierarchy�Nonec�T�tj|��D]}t||���dSr*)r�walk_subclassesr�)r�r�r�s r/�_prepare_annotationsr�Ds<���#�$4�5�5�,�,���S�(�+�+�+�+�,�,r1)r�r�rr'r(r�r*)r�r�rr'r�r�r�r$r�r$r�r�r(r�)r�r2r&r;r(r2)r�r�r&r;r(r�)r�r�r&r;r(r�)r�r�rr'r(r�)r�r�r�r�r(r�)r�r�r�r�r(r�)1r�� __future__rr�rrrrrr r r r r rrr�r� cache_keyr�visitorsrrrr� util.typingrr�baserr�strr'� EMPTY_DICTrrXr r[rrrcr�r�r�r�r�r�r�r�r!r1r/�<module>r�s������#�"�"�"�"�"� � � � ������������������������������������������������������������������� � � � � � �������������"�"�"�"�"�"�������+�+�+�+�+�+�'�'�'�'�'�'�������!�!�!�!�!�!��������1�&�&�&�&�&�&�0�0�0�0�0�0��#�s�(�#��26�/��A�A�A�A�: �: �: �: �: �/�: �: �: �z7�7�7�7�7�"5�7�7�7�tH�H�H�H�H�:�H�H�H�VH3�H3�H3�H3�H3�#�H3�H3�H3�b�������g�e�0�1�1�1�� &� &� &� &�8<�C� "'�#(� �C�C�C�C�C�C�L �>B����� ���  �48����� ��� ?C������8 � � � �,�,�,�,�^,�,�,�,�,�,r1
Memory