403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/jedi/inference/gradual/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/jedi/inference/gradual/__pycache__/annotation.cpython-311.pyc
�

p�{c<>��r�dZddlZddlmZddlmZmZddlmZddl	m
Z
mZddlm
Z
mZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZd�Zd&d�Zd�Zd�Ze��d'd���Z d�Z!d�Z"d�Z#e��d���Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d �Z,d!�Z-d"�Z.d(d$�Z/d%�Z0dS))a
PEP 0484 ( https://www.python.org/dev/peps/pep-0484/ ) describes type hints
through function annotations. There is a strong suggestion in this document
that only the type of type hinting defined in PEP0484 should be allowed
as annotations in future python versions.
�N)�	Parameter)�ParserSyntaxError�parse)�inference_state_method_cache)�ValueSet�	NO_VALUES)�DefineGenericBaseClass�GenericClass)�TupleGenericManager)�TypeVar)�	is_string)�builtin_from_name)�get_executed_param_names)�debug)�parser_utilsc�H�|�|��}t|��dkrtjd|�d|����|St	|��d}t|��r9t
||�����}|�|�|��S|S)z�
    Inferes an annotation node. This means that it inferes the part of
    `int` here:

        foo: int = 3

    Also checks for forward references (strings)
    �zInferred typing index z should lead to 1 object,  not r)�
infer_node�lenr�warning�listr
�_get_forward_reference_node�get_safe_value)�context�
annotation�	value_set�inferred_value�results     �C/usr/lib/python3/dist-packages/jedi/inference/gradual/annotation.py�infer_annotationr s����"�"�:�.�.�I�
�9�~�~����
�
�
�#-�:�:�y�y�:�	;�	;�	;����)�_�_�Q�'�N��� � �.�,�W�n�6S�6S�6U�6U�V�V�����%�%�f�-�-�-���c���t||��}|�tS|�|��}��+|��fd�������}|S)Nc�~��|jdko1tt|��������kS)N�tuple)�
array_typerr�
py__iter__)�value�indexs �r�<lambda>z*_infer_annotation_string.<locals>.<lambda>8s<���� �G�+�;���U�-�-�/�/�0�0�1�1�U�:�r!)rrr�filter�py__simple_getitem__)r�stringr(�noders  `  r�_infer_annotation_stringr.0sz���&�w��7�7�D��|����"�"�4�(�(�I����$�$�
�
�
�
�
�
�
�
�u�
%�
%�	��r!c�&�	|jj�|dd���}|j���}tj||jd��|j|_|S#t$rtjd|z��YdSwxYw)N�
eval_inputF)�start_symbol�error_recoveryrzAnnotation not parsed: %s)�inference_state�grammarr�	tree_node�
get_root_noder�move�end_pos�parentrrr)rr,�new_node�modules    rrr@s���
��*�2�8�8��%� �9�
�
���"�0�0�2�2����(�F�N�1�$5�6�6�6�!�+����������
�
�1�F�:�;�;�;��t�t����s�"A+�+!B�Bc��	t|d���jd}n)#t$rtjd|z��gcYSwxYw|jdvr'|������gSg}	|j}|D]D}|jdvr9|�|���������En#t$rgcYSwxYw|S)z�
    Split decl_text on commas, but group generic expressions
    together.

    For example, given "foo, Bar[baz, biz]" we return
    ['foo', 'Bar[baz, biz]'].

    F)r2rz*Comment annotation is not valid Python: %s)�name�	atom_expr�power)
r�childrenrrr�type�get_code�strip�append�AttributeError)�	decl_textr-�paramsr@�childs     r� _split_comment_param_declarationrIQs����Y�u�5�5�5�>�q�A��������
�
�B�Y�N�O�O�O��	�	�	������y�2�2�2��
�
���%�%�'�'�(�(�
�F�8��=���	8�	8�E��z�;�;�;��
�
�e�n�n�.�.�4�4�6�6�7�7�7��	8�������	�	�	������Ms!��#A�A�;C
�
C�CFc��t||��}|s|s|S|j}|jdkr<t|d��}t	t|t
|f����g��S|jdkr[t|d��}t	t|d��g��|f}t	t|t
|����g��S|S)Nrr$��dict�str)�_infer_paramr3�
star_countrrr
r)�function_value�param�ignore_stars�valuesr3�tuple_�dct�genericss        r�infer_paramrWps���
�.�%�
0�
0�F���6���
�$�4�O���1���"�?�G�<�<�������	�*�*�
�
����	�
�	�Q�	�	����8�8���'���?�?�@�A�A��
�������)�)�
�
����	��Mr!c���|j}|��4d�|jjD��}|jj}tj|��}|�t
St
jd|��}|st
St|�	d����}|�
|��}t|��t|��krtj
d||��|���r|dkrt
S|dz}|t|��krt
S||}	t|���|	��S|���}
t#|
|��S)zJ
    Infers the type of a function parameter, using type annotations.
    Nc�(�g|]}|jdk�
|��S)rQ)rA)�.0rHs  r�
<listcomp>z _infer_param.<locals>.<listcomp>�s.��0�0�0����w�.�.��.�.�.r!z^#\s*type:\s*\(([^#]*)\)\s*->rz&Comments length != Params length %s %sr)rr9r@r�get_following_comment_same_liner�re�matchrI�groupr(rrr�is_bound_methodr.�get_default_param_contextr )rPrQr�
all_paramsr-�commentr^�params_commentsr(�
param_commentrs           rrNrN�sv���!�J���0�0���)>�0�0�0�
��|�"���>�t�D�D���?�����9�7�C�C���	���:�5�;�;�q�>�>�J�J��� � ��'�'������3�z�?�?�2�2��M�8���
�
�
��)�)�+�+�	���z�z� � ��Q�J�E��C��(�(�(�(���'��.�
�'��4�4�6�6��
�
�	
�
�6�6�8�8�G��G�Z�0�0�0r!c��i}|���D]}|j}|�|||jj<�|j}|r||d<|S)N�return)�
get_paramsrr=r')�funcdefrU�function_param�param_annotation�return_annotations     r�py__annotations__rm�sa��
�C�!�,�,�.�.�>�>��)�4���'�-=�C��#�)�*���*���*�)��H�
��Jr!c�P����fd���fd�|���D��S)Nc���|�|jdkr|St��jj�|j����}|�dS|jd}|S)Nr,r)rArr3�compiled_subprocess�safe_literal_evalr'r@)r-rs �r�resolvez+resolve_forward_references.<locals>.resolve�sh����<�4�9��0�0��K�*���#�7�I�I��
�
�
�
�
���<��4�
�}�Q����r!c�.��i|]\}}|�|����S�rt)rZr=r-rrs   �r�
<dictcomp>z.resolve_forward_references.<locals>.<dictcomp>�s'���J�J�J�J�D�$�D�'�'�$�-�-�J�J�Jr!)�items)r�all_annotationsrrs` @r�resolve_forward_referencesrx�sF���������,K�J�J�J�/�2G�2G�2I�2I�J�J�J�Jr!c��
�|���}t|t|j����}|�dd��}|��|j}tj|��}|�tStj	d|��}|stSt||�d��������
��St||��}t||��}	|s|	�
��St!|||���
t#j�
fd�|	D�����
��S)zZ
    Infers the type of a function's return value,
    according to type annotations.
    rgNz%^#\s*type:\s*\([^#]*\)\s*->\s*([^#]*)rc3��K�|]E}t|ttf��r|����nt	|h��V��FdS�N��
isinstancer	r�define_genericsr)rZ�ann�
type_var_dicts  �r�	<genexpr>z%infer_return_types.<locals>.<genexpr>sm�������
��c�2�G�<�=�=�	S����M�*�*�*�CK�S�E�?�?������r!)rarxrmr5�getrr\rr]r^r.r_rC�execute_annotation�find_unknown_type_varsr �infer_type_vars_for_executionr�	from_sets)�function�	argumentsrrwrr-rcr^�unknown_type_vars�annotation_valuesr�s          @r�infer_return_typesr��sl����0�0�2�2�G�0���(�,�-�-���O�!�$�$�X�t�4�4�J����!���>�t�D�D���?�����A�7�K�K���	���'���K�K��N�N� � �"�"�
�
��
�
�
�	�
/�w�
�C�C��(��*�=�=���6� �3�3�5�5�5�1�(�I��W�W�M�������%����������	r!c�
�|���}i}t||��}|D]�}	||j}n#t$rY�wxYwt	||��}|r�|�|��}	|���}
|���}|
tj	ur|�
��}n#|
tjur|�d��}t||	�|������|S)aM
    Some functions use type vars that are not defined by the class, but rather
    only defined in the function. See for example `iter`. In those cases we
    want to:

    1. Search for undefined type vars.
    2. Infer type vars with the execution state we have.
    3. Return the union of all type vars that have been found.
    �_dict_values)rar�string_name�KeyErrorr�r�get_kind�inferr�VAR_POSITIONAL�merge_types_of_iterate�VAR_KEYWORD�	try_merge�merge_type_var_dicts�infer_type_vars)r�r��annotation_dictr�annotation_variable_results�executed_param_names�executed_param_name�annotation_node�annotation_variables�annotation_value_set�kind�actual_value_sets            rr�r�s6���0�0�2�2�G�"$��3�H�i�H�H��3����	�-�.A�.M�N�O�O���	�	�	��H�	���� 6�g��O�O���
	�#*�#5�#5�o�#F�#F� �&�/�/�1�1�D�2�8�8�:�:���y�/�/�/�#3�#J�#J�#L�#L� � ���.�.�.�#3�#=�#=�n�#M�#M� � �+�$�4�4�5E�F�F�
�
�
��'�&s�
:�
A�Ac���i�|D]D}|jdkr7t||�����}��|���Et	j�fd�|D�������S)Nrc3��K�|]E}t|ttf��r|����nt	|h��V��FdSr{r|)rZ�v�
all_type_varss  �rr�z,infer_return_for_callable.<locals>.<genexpr>9sl�������
��a�0�'�:�;�;�	����-�(�(�(�
�q�c�]�]������r!)r%�_infer_type_vars_for_callabler&�updaterr�r�)r��param_values�
result_values�pvr�r�s     @r�infer_return_for_callabler�2s�����M��0�0��
�=�F�"�"�9�)�R�]�]�_�_�U�U�M�� � ��/�/�/���������	�����
����r!c��i}t|���|��D]S\\}}}|���}|���}t||�|�����T|S)zn
    Infers type vars for the Calllable class:

        def x() -> Callable[[Callable[..., _T]], _T]: ...
    )�zip�unpackr�r�r�)r��lazy_paramsr��_�
lazy_value�lazy_callable_param�callable_param_valuesr�s        rr�r�As���#%��03�I�4D�4D�4F�4F��0T�0T�
�
�,���J�,� 3� 9� 9� ;� ;��%�+�+�-�-���'�!�1�1�2B�C�C�	
�	
�	
�	
�'�&r!c��|���D].\}}|r'	||xx|zcc<�#t$r|||<Y�*wxYw�/dSr{)rvr�)�	base_dict�new_dict�
type_var_namerSs    rr�r�Ss���!)���!1�!1�2�2��
�v��	2�
2��-�(�(�(�F�2�(�(�(�(���
2�
2�
2�+1�	�-�(�(�(�
2����	2�2�2s�.�A�Ac��i}t|t��s|S|���}|���}t||��D]:\}}t	||�|��������;|S)aw
    Match up the generic parameters from the given argument class to the
    target annotation.

    This walks the generic parameters immediately within the annotation and
    argument's type, in order to determine the concrete values of the
    annotation's parameters for the current case.

    For example, given the following code:

        def values(mapping: Mapping[K, V]) -> List[V]: ...

        for val in values({1: 'a'}):
            val

    Then this function should be given representations of `Mapping[K, V]`
    and `Mapping[int, str]`, so that it can determine that `K` is `int and
    `V` is `str`.

    Note that it is responsibility of the caller to traverse the MRO of the
    argument type as needed in order to find the type matching the
    annotation (in this case finding `Mapping[int, str]` as a parent of
    `Dict[int, str]`).

    Parameters
    ----------

    `annotation_value`: represents the annotation to infer the concrete
        parameter types of.

    `annotated_argument_class`: represents the annotated class of the
        argument being passed to the object annotated by `annotation_value`.
    )r}r	�get_genericsr�r�r�r�)�annotation_value�annotated_argument_classr��annotation_generics�actual_generics�annotation_generics_set�actual_generic_sets       r�merge_pairwise_genericsr�\s���F�M��.�0F�G�G����*�7�7�9�9��.�;�;�=�=�O�7:�;N�P_�7`�7`�
�
�3��!3���#�3�3�4F�4Y�4Y�4[�4[�\�\�	
�	
�	
�	
�
�r!c�<�t|||jd|��S)Nr��_find_type_from_comment_hintr@�rr-r=s   r�find_type_from_comment_hint_forr�����'���t�}�Q�7G��N�N�Nr!c��t|jdj��dks
Jd���|jdjd}t||||��S)Nr�z1Can only be here when children[1] is 'foo() as f'rK)rr@r�)rr-r=�varlists    r� find_type_from_comment_hint_withr��sX���t�}�Q��(�)�)�Q�.�.�.�;�/�.�.��m�A��'��*�G�'���w��E�E�Er!c�<�t|||jd|��S)Nrr�r�s   r�"find_type_from_comment_hint_assignr��r�r!c�X�d}|jdvr'd}|jD]}||krn|jdkr�|dz
}�gStj|��}|�gSt	jd|��}|�gSt
||�d�����|���	��S)N)�testlist_star_expr�exprlist�testlistr�operatorrz^#\s*type:\s*([^#]*))
rAr@rr\r]r^r.r_rCr�)rr-r�r=r(rHrcr^s        rr�r��s����E��|�E�E�E����%�	�	�E���}�}����z�Z�'�'���Q�J�E�E��I��:�4�@�@�G����	��H�,�g�6�6�E��}��	�#�����Q���%�%�'�'��������r!c�4�������fd��g��|���S)Nc���|jdvrW|jd}|jdkr9|jddkr*t|jd��D]}�|���dSdSdSt��|������dd�<dS)N)r>r?����trailerr�[r)rAr@�_unpack_subscriptlist�_filter_type_varsr)r-r��subscript_node�
check_noder�founds   ���rr�z*find_unknown_type_vars.<locals>.check_node�s�����9�.�.�.��m�B�'�G��|�y�(�(�W�-=�a�-@�C�-G�-G�&;�G�<L�Q�<O�&P�&P�/�/�N��J�~�.�.�.�.�)�(�-G�-G�/�/�)��);�);�D�)A�)A�5�I�I�E�!�!�!�H�H�Hr!rt)rr-r�r�s` @@rr�r��sK�����J�J�J�J�J�J�J�
�E��J�t�����Lr!rtc��t|��}|D]0}t|t��r||vr|�|���1|Sr{)rr}rrD)rr��	new_found�type_vars    rr�r��sS���U���I��'�'���h��(�(�	'�X�U�-B�-B����X�&�&�&���r!c#�K�|jdkr$|jddd�D]}|jdkr|V��dS|jdkr|V�dSdS)N�
subscriptlistrK�	subscript)rAr@)r�r�s  rr�r��s|������_�,�,�&�/���!��4�	 �	 �I��~��,�,������	 �	 ����,�,�������-�,r!r{)F)rt)1�__doc__r]�inspectr�parsorr�jedi.inference.cacher�jedi.inference.base_valuerr�jedi.inference.gradual.baser	r
�jedi.inference.gradual.genericsr�jedi.inference.gradual.type_varr�jedi.inference.helpersr
�jedi.inference.compiledr�jedi.inference.paramr�jedirrr r.rrIrWrNrmrxr�r�r�r�r�r�r�r�r�r�r�r�r�rtr!r�<module>r�s�����
�	�	�	�������*�*�*�*�*�*�*�*�=�=�=�=�=�=�9�9�9�9�9�9�9�9�L�L�L�L�L�L�L�L�?�?�?�?�?�?�3�3�3�3�3�3�,�,�,�,�,�,�5�5�5�5�5�5�9�9�9�9�9�9����������������.
�
�
�
� ���"���>������� ���0.1�.1�.1�b
�
�
�K�K�K�4����'�'� ��'�T#'�#'�#'�L���'�'�'�$2�2�2�1�1�1�hO�O�O�F�F�F�O�O�O����2������� � � � � r!

Youez - 2016 - github.com/yon3zu
LinuXploit