o
    ÕtBhà  ã                   @  s‚   U d Z ddlmZ ddlmZmZ ddlmZmZ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
„ d
ƒZdS )z—Track current scope to easily calculate the corresponding fine-grained target.

TODO: Use everywhere where we track targets, including in mypy.errors.
é    )Úannotations)ÚcontextmanagerÚnullcontext)ÚIteratorÚOptionalÚTuple)Ú	TypeAlias)ÚFuncBaseÚTypeInfoÚ
_TypeAliasÚ
SavedScopec                   @  s¢   e Zd ZdZd)dd„Zd*dd„Zd*d	d
„Zd*dd„Zd+dd„Zd+dd„Z	e
d,dd„ƒZe
d-dd„ƒZd.dd„Zd)dd„Ze
d/d d!„ƒZd0d#d$„Ze
d1d&d'„ƒZd(S )2ÚScopez7Track which target we are processing at any given time.ÚreturnÚNonec                 C  s   d | _ g | _d | _d| _d S ©Nr   ©ÚmoduleÚclassesÚfunctionÚignored©Úself© r   úa/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypy/scope.pyÚ__init__   s   
zScope.__init__Ústrc                 C  s   | j sJ ‚| j S ©N)r   r   r   r   r   Úcurrent_module_id   s   
zScope.current_module_idc                 C  s&   | 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   r   r   r   Úcurrent_target   s
   
zScope.current_targetc                 C  s0   | 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   r   r   r   Úcurrent_full_target'   s   
zScope.current_full_targetú
str | Nonec                 C  s   | j r	| j d jS dS )z1Return the current type's short name if it existsr!   N)r   Únamer   r   r   r   Úcurrent_type_name0   s   zScope.current_type_namec                 C  s   | j r| j jS dS )z5Return the current function's short name if it existsN)r   r$   r   r   r   r   Úcurrent_function_name4   s   zScope.current_function_nameÚprefixúIterator[None]c                 c  s4    || _ g | _d | _d| _d V  | j sJ ‚d | _ d S r   r   )r   r'   r   r   r   Úmodule_scope8   s   €

zScope.module_scopeÚfdefr	   c                 c  sP    | j s|| _ n|  jd7  _d V  | jr|  jd8  _d S | j s#J ‚d | _ d S )Né   )r   r   )r   r*   r   r   r   Úfunction_scopeB   s   €

zScope.function_scopeÚinfor
   c                 C  s(   | j s| j |¡ dS |  jd7  _dS )zEnter a class target scope.r+   N)r   r   Úappendr   ©r   r-   r   r   r   Úenter_classQ   s   zScope.enter_classc                 C  s0   | j r|  j d8  _ dS | jsJ ‚| j ¡  dS )zLeave a class target scope.r+   N)r   r   Úpopr   r   r   r   Úleave_classY   s   
zScope.leave_classc                 c  s    |   |¡ d V  |  ¡  d S r   )r0   r2   r/   r   r   r   Úclass_scopec   s   €
zScope.class_scoper   c                 C  s,   | 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   Úclsr   r   r   Úsavei   s   
z
Scope.saveÚsavedc              
   c  sº    |\}}}|   |¡H |r|  |¡ntƒ % |r|  |¡ntƒ  d V  W d   ƒ n1 s/w   Y  W d   ƒ n1 s>w   Y  W d   ƒ d S W d   ƒ d S 1 sVw   Y  d S r   )r)   r3   r   r,   )r   r6   r   r-   r   r   r   r   Úsaved_scopeq   s   €
ÿ€ÿÿ"ÿzScope.saved_scopeN)r   r   )r   r   )r   r#   )r'   r   r   r(   )r*   r	   r   r(   )r-   r
   r   r   )r-   r
   r   r(   )r   r   )r6   r   r   r(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r    r"   r%   r&   r   r)   r,   r0   r2   r3   r5   r7   r   r   r   r   r      s&    




	
	



r   N)r;   Ú
__future__r   Ú
contextlibr   r   Útypingr   r   r   Útyping_extensionsr   r   Ú
mypy.nodesr	   r
   r   r   Ú__annotations__r   r   r   r   r   Ú<module>   s    