
    i                        U d dl mZ d dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZ eeegdf         Zded<    G d	 d
e          Z G d d          ZdS )    )annotations)Callable)	TypeAlias)ContextParamSpecExprSymbolTableNodeTypeVarExprTypeVarLikeExprTypeVarTupleExpr)AnyTypeParamSpecFlavorParamSpecTypeTrivialSyntheticTypeTranslatorTypeTypeAliasType	TypeOfAny	TypeVarIdTypeVarLikeTypeTypeVarTupleTypeTypeVarTypeN
_TypeAliasFailFuncc                  L     e Zd ZdZd fdZddZddZddZddZddZ	 xZ
S ) TypeVarLikeDefaultFixerz-Set namespace for all TypeVarLikeTypes types.scopeTypeVarLikeScope	fail_funcr   	source_tvr
   contextr   returnNonec                    || _         || _        || _        || _        t	                                                       d S N)r   r   r   r   super__init__)selfr   r   r   r   	__class__s        N/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypy/tvar_scope.pyr%   z TypeVarLikeDefaultFixer.__init__"   s=     
""    tr   r   c                    | j                             |j                  }|.|                     |           t	          t
          j                  S |S r#   r   get_bindingfullname_report_unbound_tvarr   r   
from_errorr&   r*   existings      r(   visit_type_varz&TypeVarLikeDefaultFixer.visit_type_var/   I    :))!*55%%a(((9/000r)   r   c                    | j                             |j                  }|.|                     |           t	          t
          j                  S |S r#   r,   r1   s      r(   visit_param_specz(TypeVarLikeDefaultFixer.visit_param_spec6   r4   r)   r   c                    | j                             |j                  }|.|                     |           t	          t
          j                  S |S r#   r,   r1   s      r(   visit_type_var_tuplez,TypeVarLikeDefaultFixer.visit_type_var_tuple=   r4   r)   r   c                    |S r#    )r&   r*   s     r(   visit_type_alias_typez-TypeVarLikeDefaultFixer.visit_type_alias_typeD   s    r)   tvarr   c                h    |                      d|j         d| j        j         d| j                   d S )NzType variable z referenced in the default of z is unbound)r   namer   r   )r&   r<   s     r(   r/   z,TypeVarLikeDefaultFixer._report_unbound_tvarG   sQ    4TY 4 4>&4 4 4L	
 	
 	
 	
 	
r)   )
r   r   r   r   r   r
   r   r   r    r!   )r*   r   r    r   )r*   r   r    r   )r*   r   r    r   )r*   r   r    r   )r<   r   r    r!   )__name__
__module____qualname____doc__r%   r3   r6   r8   r;   r/   __classcell__)r'   s   @r(   r   r      s        77                 
 
 
 
 
 
 
 
r)   r   c                  l    e Zd ZdZ	 	 	 	 d&d'dZd(dZd)dZd*dZd*dZd+dZ	d,dZ
d-d Zd.d$Zd/d%ZdS )0r   zvScope that holds bindings for type variables and parameter specifications.

    Node fullname -> TypeVarLikeType.
    NF parentTypeVarLikeScope | Noneis_class_scopebool
prohibited	namespacestrr    r!   c                    i | _         || _        d| _        d| _        || _        || _        || _        ||j        | _        |j        | _        dS dS )aV  Initializer for TypeVarLikeScope

        Parameters:
          parent: the outer scope for this scope
          is_class_scope: True if this represents a generic class
          prohibited: Type variables that aren't strictly in scope exactly,
                      but can't be bound because they're part of an outer class's scope.
        r   N)r   rF   func_idclass_idrH   rJ   rK   )r&   rF   rH   rJ   rK   s        r(   r%   zTypeVarLikeScope.__init__U   sZ     24
,$"!>DL"ODMMM r)   c                <    | }||j         r|j        }||j         |S )zAGet the nearest parent that's a function scope, not a class scope)rH   rF   )r&   its     r(   get_function_scopez#TypeVarLikeScope.get_function_scopeo   s-    &*n!2nB n!2n	r)   r.   c                    || j         v rdS | j        r| j                            |          sdS | j        r| j                            |          sdS dS )NFT)r   rF   allow_bindingrJ   )r&   r.   s     r(   rT   zTypeVarLikeScope.allow_bindingv   se    tz!!5[ 	!:!:8!D!D 	5_ 	T_%B%B8%L%L 	5tr)   c                (    t          | dd|          S )z&A new scope frame for binding a methodFNrK   )r   r&   rK   s     r(   method_framezTypeVarLikeScope.method_frame   s    eTYGGGGr)   c                L    t          |                                 d| |          S )zEA new scope frame for binding a class. Prohibits *this* class's tvarsTrV   )r   rR   rW   s     r(   class_framezTypeVarLikeScope.class_frame   s&     7 7 9 94QZ[[[[r)   r   c                J    | xj         dz  c_         t          | j                   S )zHUsed by plugin-like code that needs to make synthetic generic functions.   )rN   r   )r&   s    r(   new_unique_func_idz#TypeVarLikeScope.new_unique_func_id   s"    &&&r)   r>   	tvar_exprr
   r   r   r   r   r   c                   | j         r| xj        dz  c_        | j        }n| xj        dz  c_        | j        }| j        }|j                            t          | |||                    }t          |t                    rFt          ||j
        t          ||          |j        |j        ||j        |j        |j        	  	        }nt          |t"                    rEt%          ||j
        t          ||          t&          j        |j        ||j        |j                  }nWt          |t*                    r@t-          ||j
        t          ||          |j        |j        ||j        |j                  }nJ || j        |j
        <   |S )Nr\   )r   r   r   rV   )	r>   r.   idvaluesupper_bounddefaultvariancelinecolumn)r>   r.   r`   flavorrb   rc   re   rf   )r>   r.   r`   rb   tuple_fallbackrc   re   rf   )rH   rO   rN   rK   rc   acceptr   
isinstancer	   r   r.   r   ra   rb   rd   re   rf   r   r   r   BAREr   r   rh   r   )	r&   r>   r^   r   r   irK   rc   tvar_defs	            r(   bind_newzTypeVarLikeScope.bind_new   s     	MMQMMAALLALLAN	
 #**#	Y  
 
 i-- #	(3"+Q)444 '%1"+^ '
) 
) 
)HH 	=11 	$"+Q)444&+%1^ '	 	 	HH 	#344 	'"+Q)444%1(7^ '	 	 	HH L)1
9%&r)   rm   c                $    || j         |j        <   d S r#   )r   r.   )r&   rm   s     r(   bind_existingzTypeVarLikeScope.bind_existing   s    (0
8$%%%r)   itemstr | SymbolTableNodeTypeVarLikeType | Nonec                    t          |t                    r|j        n|}|sJ || j        v r| j        |         S | j        | j                            |          S d S r#   )rj   r   r.   r   rF   r-   )r&   rq   r.   s      r(   r-   zTypeVarLikeScope.get_binding   sb    $.t_$E$EO4==4tz!!:h''[$;**84444r)   c                    d                     d | j                                        D                       }| j        |S | j         d| S )Nz, c              3  D   K   | ]\  }}| d |j          d|j         V  dS )z: `N)r>   r`   ).0kvs      r(   	<genexpr>z+TypeVarLikeScope.__str__.<locals>.<genexpr>   s@      NN41a!..qv....NNNNNNr)   z <- )joinr   itemsrF   )r&   mes     r(   __str__zTypeVarLikeScope.__str__   sS    YYNN4:;K;K;M;MNNNNN;I+''2'''r)   )NFNrE   )
rF   rG   rH   rI   rJ   rG   rK   rL   r    r!   )r    rG   )r.   rL   r    rI   )rK   rL   r    r   )r    r   )
r>   rL   r^   r
   r   r   r   r   r    r   )rm   r   r    r!   )rq   rr   r    rs   )r    rL   )r?   r@   rA   rB   r%   rR   rT   rX   rZ   r]   rn   rp   r-   r   r:   r)   r(   r   r   O   s         +/$.2, , , , ,4      H H H H\ \ \ \' ' ' '
9 9 9 9v1 1 1 1   ( ( ( ( ( (r)   r   )
__future__r   collections.abcr   typingr   r   
mypy.nodesr   r   r   r	   r
   r   
mypy.typesr   r   r   r   r   r   r   r   r   r   r   rL   r   __annotations__r   r   r:   r)   r(   <module>r      s   " " " " " " " $ $ $ $ $ $ * * * * * *                                          g 45 5 5 5 5-
 -
 -
 -
 -
< -
 -
 -
`I( I( I( I( I( I( I( I( I( I(r)   