
    X-Ph                        d dl mZ d dl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 d dlmZ  G d de          Z G d d          Zd	S )
    )annotations)ParamSpecExprSymbolTableNodeTypeVarExprTypeVarLikeExprTypeVarTupleExpr)ParamSpecFlavorParamSpecType	TypeVarIdTypeVarLikeTypeTypeVarTupleTypeTypeVarType)TypeTraverserVisitorc                  D     e Zd ZdZddZd fd	Zd fdZd fdZ xZS )TypeVarLikeNamespaceSetterz-Set namespace for all TypeVarLikeTypes types.	namespacestrreturnNonec                    || _         d S Nr   selfr   s     O/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/tvar_scope.py__init__z#TypeVarLikeNamespaceSetter.__init__   s    "    tr   c                l    | j         |j        _         t                                          |           d S r   )r   idsupervisit_type_varr   r   	__class__s     r   r"   z)TypeVarLikeNamespaceSetter.visit_type_var   s,    q!!!!!r   r
   c                h    | j         |j        _         t                                          |          S r   )r   r    r!   visit_param_specr#   s     r   r&   z+TypeVarLikeNamespaceSetter.visit_param_spec   s&    ww''***r   r   c                l    | j         |j        _         t                                          |           d S r   )r   r    r!   visit_type_var_tupler#   s     r   r(   z/TypeVarLikeNamespaceSetter.visit_type_var_tuple#   s,    $$Q'''''r   )r   r   r   r   )r   r   r   r   )r   r
   r   r   )r   r   r   r   )	__name__
__module____qualname____doc__r   r"   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 ),TypeVarLikeScopezvScope that holds bindings for type variables and parameter specifications.

    Node fullname -> TypeVarLikeType.
    NF parentTypeVarLikeScope | Noneis_class_scopebool
prohibitedr   r   r   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)scoper1   func_idclass_idr3   r5   r   )r   r1   r3   r5   r   s        r   r   zTypeVarLikeScope.__init__.   sZ     24
,$"!>DL"ODMMM r   c                <    | }||j         r|j        }||j         |S )zAGet the nearest parent that's a function scope, not a class scope)r3   r1   )r   its     r   get_function_scopez#TypeVarLikeScope.get_function_scopeH   s-    &*n!2nB n!2n	r   fullnamec                    || j         v rdS | j        r| j                            |          sdS | j        r| j                            |          sdS dS )NFT)r7   r1   allow_bindingr5   )r   r=   s     r   r?   zTypeVarLikeScope.allow_bindingO   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 methodFNr   )r/   r   s     r   method_framezTypeVarLikeScope.method_frameX   s    eTYGGGGr   c                L    t          |                                 d| |          S )zEA new scope frame for binding a class. Prohibits *this* class's tvarsTr   )r/   r<   r   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.   )r8   r   )r   s    r   new_unique_func_idz#TypeVarLikeScope.new_unique_func_id`   s"    &&&r   name	tvar_exprr   r   c                "   | j         r| xj        dz  c_        | j        }n| xj        dz  c_        | j        }| j        }|j                            t          |                     t          |t                    rKt          ||j
        t          ||          |j        |j        |j        |j        |j        |j        	  	        }nt          |t"                    rJt%          ||j
        t          ||          t&          j        |j        |j        |j        |j                  }n\t          |t*                    rEt-          ||j
        t          ||          |j        |j        |j        |j        |j                  }nJ || j        |j
        <   |S )NrE   r   )	rG   r=   r    valuesupper_bounddefaultvariancelinecolumn)rG   r=   r    flavorrK   rL   rN   rO   )rG   r=   r    rK   tuple_fallbackrL   rN   rO   )r3   r9   r8   r   rL   acceptr   
isinstancer   r   r=   r   rJ   rK   rM   rN   rO   r   r
   r	   BAREr   r   rQ   r7   )r   rG   rH   ir   tvar_defs         r   bind_newzTypeVarLikeScope.bind_newe   s    	MMQMMAALLALLAN	  !;I!F!FGGG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   rV   c                $    || j         |j        <   d S r   )r7   r=   )r   rV   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   )rS   r   r=   r7   r1   get_binding)r   rZ   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)rG   r    ).0kvs      r   	<genexpr>z+TypeVarLikeScope.__str__.<locals>.<genexpr>   s@      NN41a!..qv....NNNNNNr   z <- )joinr7   itemsr1   )r   mes     r   __str__zTypeVarLikeScope.__str__   sS    YYNN4:;K;K;M;MNNNNN;I+''2'''r   )NFNr0   )
r1   r2   r3   r4   r5   r2   r   r   r   r   )r   r2   )r=   r   r   r4   )r   r   r   r/   )r   r   )rG   r   rH   r   r   r   )rV   r   r   r   )rZ   r[   r   r\   )r   r   )r)   r*   r+   r,   r   r<   r?   rA   rC   rF   rW   rY   r^   ri    r   r   r/   r/   (   s         +/$.2, , , , ,4      H H H H\ \ \ \' ' ' '
/ / / /b1 1 1 1   ( ( ( ( ( (r   r/   N)
__future__r   
mypy.nodesr   r   r   r   r   
mypy.typesr	   r
   r   r   r   r   mypy.typetraverserr   r   r/   rj   r   r   <module>ro      s(   " " " " " "                             4 3 3 3 3 3( ( ( ( (!5 ( ( (&( ( ( ( ( ( ( ( ( (r   