PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/sqlalchemy/ext/mypy/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/sqlalchemy/ext/mypy/__pycache__/infer.cpython-312.pyc

�

���g�K��r�ddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"												d(d�Z#										d)d�Z$										d)d�Z%												d(d �Z&										d)d!�Z'	d*											d+d#�Z(		d,													d-d$�Z)										d.d%�Z*								d/d&�Z+								d0d'�Z,y")1�)�annotations)�Optional)�Sequence)�map_instance_to_supertype)�AssignmentStmt)�CallExpr)�
Expression)�FuncDef)�
LambdaExpr)�
MemberExpr)�NameExpr)�RefExpr)�StrExpr)�TypeInfo)�Var)�SemanticAnalyzerPluginInterface)�
is_subtype)�AnyType)�CallableType)�get_proper_type)�Instance)�NoneType)�
ProperType)�	TypeOfAny)�	UnionType�)�names)�utilc���tj|�}|�y|tjurt|||||�}|S|tjurt||||�}|S|tjurt||||�}|S|tjurt||||�}|S|tjurt|||�}|S|tjurt||||�}|Sy�N)r�type_id_for_callee�MAPPED�_infer_type_from_mapped�COLUMN�_infer_type_from_decl_column�RELATIONSHIP�_infer_type_from_relationship�COLUMN_PROPERTY�%_infer_type_from_decl_column_property�SYNONYM_PROPERTY�#infer_type_from_left_hand_type_only�COMPOSITE_PROPERTY�(_infer_type_from_decl_composite_property)�api�stmt�node�left_hand_explicit_type�infer_from_right_side�type_id�python_type_for_types       �J/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/ext/mypy/infer.py�#infer_type_from_right_hand_nameexprr6(s+���&�&�'<�=�G����	�E�L�L�	 �6���t�4�6K� 
��4 ��/
�E�L�L�	 �;���t�4� 
��, ��'
�E�&�&�	&�<���t�4� 
��$ ��
�E�)�)�	)�D���t�4� 
�� ��
�E�*�*�	*�B���.� 
�� ��
�E�,�,�	,�G���t�4� 
�� ���c��t|jt�sJ�|jjd}d}t|t�r2t|j
t�r|j
}t|g�}tj|jd�}tj|jd�}d}	|�=|j|�dur*|�(d}	|��&|jtj|g�}�n|�|j|�du�ri|��fd}	t|t�r|j}t|t�r6t|j
t�r|���t|j
|g�}�n�t|t�r�t|j
t�r�|j
j ��|��Ct|j
j t"��rt%|j
j j&�}
t|
t"�r�t%|
j&�}t|t�r�t|j |g�}n�tj(|d|j�d}n�|�N|j|�dur;|�!tj(|d|j�|�Jt+|t-�g�}n4|�2d	}tj(||j/|j0�|�|�
t3|||�S|�B|	r2t|t�sJ�t|t�sJ�t5||||�St7||||�S|S)
a�Infer the type of mapping from a relationship.

    E.g.::

        @reg.mapped
        class MyClass:
            # ...

            addresses = relationship(Address, uselist=True)

            order: Mapped["Order"] = relationship("Order")

    Will resolve in mypy as::

        @reg.mapped
        class MyClass:
            # ...

            addresses: Mapped[List[Address]]

            order: Mapped["Order"]

    rN�uselist�collection_classFTz>Expected Python collection type for collection_class parameterzOSending uselist=False and collection_class at the same time does not make sensez�Can't infer scalar or collection for ORM mapped expression assigned to attribute '{}' if both 'uselist' and 'collection_class' arguments are absent from the relationship(); please specify a type annotation on the left hand side.)�
isinstance�rvaluer�argsr
r0rrr�get_callexpr_kwarg�
parse_bool�
named_typer�NAMED_TYPE_BUILTINS_LIST�calleer
�typerr�ret_type�failrr�format�namer+�3_infer_collection_type_from_left_and_inferred_right�(_infer_type_from_left_and_inferred_right)
r.r/r0r1�target_cls_argr4�related_object_type�uselist_arg�collection_cls_arg�type_is_a_collection�rt�callable_ret_type�msgs
             r5r'r'PsA��<�d�k�k�8�,�,�,��[�[�%�%�a�(�N�15���.�(�+�
����X�1�-�1�1��'�(;�R�@�� �)�)�$�+�+�y�A�K�/3�/F�/F����'�0��!��	���N�N�;�'�4�/��&�#���+�#&�>�>��.�.�1E�0F�$� �	��s�~�~�k�:�d�B�
�
(�#���(�(�3�!3�!:�!:���(�(�3�
��#�#�X�9
�$�/�(0�&�+�+�.B�-C�(�$�
�)�8�4��-�2�2�G�<�"�'�'�,�,�8�#�/�
�0�5�5�:�:�L�I�(�);�)@�)@�)E�)E�)N�)N�O�B�!�"�l�3�,;�B�K�K�,H�)�%�&7��B�3;� 1� 6� 6�!5� 6�4�0�

�I�I��-����	
�$(� �	�	 �S�^�^�K�%@�E�%I��)��I�I��&����	
� �+�#,�%�x�z�2�$� �
#�*�9�
�
�I�I�c�3�:�:�d�i�i�0�$�7��#�2���.�
�	
�
!�	,���5�x�@�@�@��2�H�=�=�=�F��T�2�4H��
�<���'�$�	�
�$�#r7c�<�t|jt�sJ�|jjd}d}t|t�r3t|j
t�r|j
}t|g�}nd}|�
t|||�S|�t||||�S|S)z+Infer the type of mapping from a Composite.rN)
r;r<rr=r
r0rrr+rI)r.r/r0r1rJr4rKs       r5r-r-�s����d�k�k�8�,�,�,��[�[�%�%�a�(�N����.�(�+�
����X�1�-�1�1��'�(;�R�@��#���#�2���.�
�	
�
!�	,�7���.�0D�
�	
�$�#r7c�~�t|jt�sJ�tj|�}t|||�S)zVInfer the type of mapping from a right side expression
    that returns Mapped.


    )r;r<rr�type_for_calleer+)r.r/r0r1r2�the_mapped_types      r5r#r#s@���d�k�k�8�,�,�,��*�*�+@�A�O�.��T�*��r7c��t|jt�sJ�|jjrj|jjd}t|t�rAt	j
|j�}|tjurt|||||��St|jt�rIt	j
|jj�}|tjurt||||�St|||�S)z�Infer the type of mapping from a ColumnProperty.

    This includes mappings against ``column_property()`` as well as the
    ``deferred()`` function.

    r)�right_hand_expression)r;r<rr=rr!rBr$r%�QUERY_EXPRESSIONr+)r.r/r0r1�first_prop_argr3s      r5r)r)6s����d�k�k�8�,�,�,��{�{������)�)�!�,���n�h�/��.�.�~�/D�/D�E�G��%�,�,�&�3����+�*8����$�+�+�x�(��*�*�4�;�;�+=�+=�>���e�,�,�,�/����'�	�
�/��T�*��r7Nc�"�t|t�sJ�d}|�'t|jt�sy|j}|jddD]�}t|t�r5t|j
t�s�.|j
}|j}n^t|ttf�r!t|jt�r|}d}n(�t|tf�r��t|tf�r��J�|�yt|jt�rttj|jjtj �r<t#||j�}|�t%||||�St'|t)�g�St+|||�S)a�Infer the type of mapping from a Column.

    E.g.::

        @reg.mapped
        class MyClass:
            # ...

            a = Column(Integer)

            b = Column("b", String)

            c: Mapped[int] = Column(Integer)

            d: bool = Column(Boolean)

    Will resolve in MyPy as::

        @reg.mapped
        class MyClass:
            # ...

            a: Mapped[int]

            b: Mapped[str]

            c: Mapped[int]

            d: Mapped[bool]

    Nr��)r;rr<rr=rBrr
rr0rrrr�
mro_has_id�mro�
TYPEENGINE�#extract_python_type_from_typeenginerIrrr+)	r.r/r0r1rWrB�
column_arg�	type_argsr4s	         r5r%r%gst��L�d�C� � � �
�F��$��$�+�+�x�0�� $����+�0�0��1�5�
��j�(�+��*�+�+�W�5�#�*�*��2<�/�/�	��
�
�X�z�$:�
;��*�/�/�8�4�#���	���
�
�W�J�
/��
�
�Z�M�
2�
��5�16�4�~���&�+�+�x�(�U�-=�-=�������)�)�.� C�����i� 
��#�.�;��T�2�4H��
�
�2�H�J�?�@�@�3���.�
�	
r7c�P�|�|}|�|}t||�s�|jtj|g�}d}t	j
||j
|jt	j||j�t	j||j��|�|S)z�Validate type when a left hand annotation is present and we also
    could infer the right hand side::

        attrname: SomeType = Column(SomeDBType)

    zRLeft hand assignment '{}: {}' not compatible with ORM mapped expression of type {})
rr@r�NAMED_TYPE_SQLA_MAPPEDrrErFrG�format_type�options)r.r0r1r4�orig_left_hand_type�orig_python_type_for_type�effective_typerQs        r5rIrI�s����"�5�� �(�$8�!��-�/C�D�����(�(�+D�*E�
��

4�	�	
�	�	���J�J��	�	�� � �!4�c�k�k�B�� � �����=�
�

�	
��r7c��|}|}|jr1t|jd�}t|jd�}n|}|}t|ttf�sJ�t|ttf�sJ�t||||||��S)Nr)rgrh)r=rr;rrrI)r.r0r1r4rgrh�
left_hand_arg�python_type_args        r5rHrH�s���2�� 4���#�#�'�(?�(D�(D�Q�(G�H�
�)�*>�*C�*C�A�*F�G��/�
�.���m�h�	�%:�;�;�;��o��)�'<�=�=�=�3�����/�";�
�r7c���|�jd}tj||j|j�|�|j	t
jttj�g�S|S)z�Determine the type based on explicit annotation only.

    if no annotation were present, note that we need one there to know
    the type.

    z�Can't infer type from ORM mapped expression assigned to attribute '{}'; please specify a Python type or Mapped[<python type>] on the left hand side.)
rrErFrGr@rrdrr�special_form)r.r0r1rQs    r5r+r+se���&�
;�	�	
�	�	�#�s�z�z�$�)�)�,�d�3��~�~��(�(�7�9�3I�3I�+J�*K�
�	
�'�&r7c�L�|jdk(r�|r�|d}t|t�r]t|jt�rC|jj
D])}|jdk(s�t
|jg�cSn |jtjg�S|jd�s
Jd|z��|jd�}|�t|jt�sJ�tt
|g�|j�}t|jd�S)Nzsqlalchemy.sql.sqltypes.Enumrz	enum.Enumz"sqlalchemy.sql.type_api.TypeEnginez+could not extract Python type from node: %s���)�fullnamer;rr0rr^rr@r�NAMED_TYPE_BUILTINS_STR�has_base�lookup_fully_qualified_or_nonerrr=)r.r0rb�	first_arg�base_�type_engine_sym�type_engines       r5r`r`.s��
�}�}�6�6�9��a�L�	��i��)�j��N�N�H�/
�#���+�+���>�>�[�0�#�I�N�N�B�7�7�,�
�>�>�%�"?�"?��D�D��=�=�=�>��5��<��>��8�8�,��O��&�:����h�,���,���r������K��;�+�+�B�/�0�0r7)r.rr/rr0rr1�Optional[ProperType]r2r�returnry)
r.rr/rr0rr1ryrzryr )r.rr/rr0rr1ryrWzOptional[CallExpr]rzry)NN)r.rr0rr1rr4rrgryrhryrzry)
r.rr0rr1rr4rrzry)r.rr0rr1ryrzry)r.rr0rrbzSequence[Expression]rzr)-�
__future__r�typingrr�mypy.maptyper�
mypy.nodesrrr	r
rrr
rrrr�mypy.pluginr�
mypy.subtypesr�
mypy.typesrrrrrrrr�rrr6r'r-r#r)r%rIrHr+r`r\r7r5�<module>r�s���#���2�%��!��!�!������7�$��#�&���!� � ���% �	(�% �
�% ��% �2�	% �
#�% ��
% �Pc$�	(�c$�
�c$��c$�2�	c$�
�c$�L$�	(�$�
�$��$�2�	$�
�$�@�	(��
����2�	�
#���
�@.�	(�.�
�.��.�2�	.�
�.�l15�`
�	(�`
�
�`
��`
�2�	`
�
.�`
��
`
�P15�6:�
'�	(�'�

�'�(�'�%�	'�
.�'� 4�
'��'�T�	(��

��&��#�	�
��:'�	(�'�

�'�2�'��	'�: 1�	(� 1�
� 1�$� 1��	 1r7

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic