
    X-Ph                        U d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZmZ eee	e         e	e         f         Zded	<    G d
 d          ZdS )zTrack current scope to easily calculate the corresponding fine-grained target.

TODO: Use everywhere where we track targets, including in mypy.errors.
    )annotations)Iterator)contextmanagernullcontext)Optional)	TypeAlias)FuncBaseTypeInfo
_TypeAlias
SavedScopec                      e Zd ZdZddZddZddZddZd d
Zd dZ	e
d!d            Ze
d"d            Zd#dZd$dZddZe
d%d            Zd&dZe
d'd            ZdS )(Scopez7Track which target we are processing at any given time.returnNonec                L    d | _         g | _        d | _        g | _        d| _        d S Nr   )moduleclassesfunction	functionsignoredselfs    J/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypy/scope.py__init__zScope.__init__   s)    "&'))-)+    strc                "    | j         sJ | j         S N)r   r   s    r   current_module_idzScope.current_module_id   s    {{r   c                P    | j         sJ | j        r| j        j        }|pdS | j         S )zKReturn the current target (non-class; for a class return enclosing module). )r   r   fullname)r   r#   s     r   current_targetzScope.current_target!   s6    {= 	"}-H>r!{r   c                z    | j         sJ | j        r| j        j        S | j        r| j        d         j        S | j         S )z+Return the current target (may be a class).)r   r   r#   r   r   s    r   current_full_targetzScope.current_full_target)   sG    {= 	*=))< 	-<#,,{r   
str | Nonec                8    | j         r| j         d         j        ndS )z1Return the current type's short name if it existsr&   N)r   namer   s    r   current_type_namezScope.current_type_name2   s    (,>t|B$$$>r   c                ,    | j         r| j         j        ndS )z5Return the current function's short name if it existsN)r   r*   r   s    r   current_function_namezScope.current_function_name6   s    %)]<t}!!<r   prefixIterator[None]c              #  j   K   || _         g | _        d | _        d| _        d V  | j         sJ d | _         d S r   )r   r   r   r   )r   r.   s     r   module_scopezScope.module_scope:   sD      {r   fdefr	   c              #    K   | j                             |           | j        s|| _        n| xj        dz  c_        d V  | j                                          | j        r| xj        dz  c_        d S | j        sJ d | _        d S )N   )r   appendr   r   pop)r   r2   s     r   function_scopezScope.function_scopeD   s      d###} 	 DMM LLALL< 	!LLALLLL=    DMMMr   list[FuncBase]c                     | j         d d         S )Nr&   )r   r   s    r   outer_functionszScope.outer_functionsU   s    ~crc""r   infor
   c                l    | j         s| j                            |           dS | xj        dz  c_        dS )zEnter a class target scope.r4   N)r   r   r5   r   r   r;   s     r   enter_classzScope.enter_classX   s>    } 	L%%%%% LLALLLLr   c                |    | j         r| xj         dz  c_         dS | j        sJ | j                                         dS )zLeave a class target scope.r4   N)r   r   r6   r   s    r   leave_classzScope.leave_class`   sH    < 	LLALLLL<Lr   c              #  d   K   |                      |           d V  |                                  d S r   )r>   r@   r=   s     r   class_scopezScope.class_scopej   s;      r   r   c                ^    | j         sJ | j        r| j        d         nd}| j         || j        fS )z<Produce a saved scope that can be entered with saved_scope()r&   N)r   r   r   )r   clss     r   savez
Scope.savep   s;    { #',8dl2D{C..r   savedc              #  n  K   |\  }}}|                      |          5  |r|                     |          nt                      5  |r|                     |          nt                      5  d V  d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r   )r1   rB   r   r7   )r   rF   r   r;   r   s        r   saved_scopezScope.saved_scopex   s     !&hv&& 	 	+/B!!$'''[]]  6>QT((222KMM  EEE                            	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sY   &B*&B*A;/B;A??BA?BB*B	B*B	B**B.1B.N)r   r   )r   r   )r   r(   )r.   r   r   r/   )r2   r	   r   r/   )r   r8   )r;   r
   r   r   )r;   r
   r   r/   )r   r   )rF   r   r   r/   )__name__
__module____qualname____doc__r   r    r$   r'   r+   r-   r   r1   r7   r:   r>   r@   rB   rE   rH    r   r   r   r      sb       AA            ? ? ? ?= = = =    ^ ! ! ! ^! # # # #          ^
/ / / /    ^  r   r   N)rL   
__future__r   collections.abcr   
contextlibr   r   typingr   typing_extensionsr   r   
mypy.nodesr	   r
   tupler   r   __annotations__r   rM   r   r   <module>rV      s     
 # " " " " " $ $ $ $ $ $ 2 2 2 2 2 2 2 2       5 5 5 5 5 5 ) ) ) ) ) ) ) )sHX$68JJK
 K K K Kl l l l l l l l l lr   