
    i                        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mZ eeedz  edz  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)	TypeAlias)FuncBaseTypeInfoN
_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    I/root/projects/qq-shell/venv/lib64/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_name1   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_name5   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_scope9   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   r1   s     r   function_scopezScope.function_scopeC   s      d###} 	 DMM LLALL< 	!LLALLLL=    DMMMr   list[FuncBase]c                     | j         d d         S )Nr%   )r   r   s    r   outer_functionszScope.outer_functionsT   s    ~crc""r   infor	   c                l    | j         s| j                            |           dS | xj        dz  c_        dS )zEnter a class target scope.r3   N)r   r   r4   r   r   r:   s     r   enter_classzScope.enter_classW   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.r3   N)r   r   r5   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_scopei   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.saveo   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   )r0   rA   r   r6   )r   rE   r   r:   r   s        r   saved_scopezScope.saved_scopew   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.   )r1   r   r   r.   )r   r7   )r:   r	   r   r   )r:   r	   r   r.   )r   r   )rE   r   r   r.   )__name__
__module____qualname____doc__r   r   r#   r&   r*   r,   r   r0   r6   r9   r=   r?   rA   rD   rG    r   r   r   r      sb       AA            ? ? ? ?= = = =    ^ ! ! ! ^! # # # #          ^
/ / / /    ^  r   r   )rK   
__future__r   collections.abcr   
contextlibr   r   typingr   r
   
mypy.nodesr   r	   tupler   r   __annotations__r   rL   r   r   <module>rT      s     
 # " " " " " $ $ $ $ $ $ 2 2 2 2 2 2 2 2 * * * * * * ) ) ) ) ) ) ) )sHtOX_DE
 E E E El l l l l l l l l lr   