o
    g                     @   sj   d Z ddlZddlZddlmZ ddlmZmZmZ ddlmZ	 ddl
mZ G dd dejZd	d
 ZdS )z=Checker for anything related to the async protocol (PEP 492).    N)nodes)checkers
interfacesutils)r   )decorated_withc                   @   s|   e Zd ZejZdZdddddifddd	ddifd
Zdd Ze	
ddejddfddZe	
ddejddfddZdS )AsyncCheckerasynczYield inside async functionyield-inside-async-functionzQUsed when an `yield` or `yield from` statement is found inside an async function.
minversion      zFAsync context manager '%s' doesn't implement __aenter__ and __aexit__.not-async-context-managerzxUsed when an async context manager is used with an object that does not implement the async context management protocol.)E1700E1701c                 C   s   t | d| _dg| _d S )Nzignore-mixin-memberszcontextlib.asynccontextmanager)r   get_global_option_ignore_mixin_members_async_generators)self r   S/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/checkers/async.pyopen+   s   zAsyncChecker.opennodereturnNc                 C   sN   | tjD ]}| |u r$tjd d dkst|tjr$| jd|d qd S )N   r   r	   )r   )	nodes_of_classr   Yieldscopesysversion_info
isinstance	YieldFromadd_message)r   r   childr   r   r   visit_asyncfunctiondef1   s   z#AsyncChecker.visit_asyncfunctiondefc              	   C   s   |j D ]q\}}t|}|d u s|tju rqt|tjr$t|| j	r#qnFt|tj
jr4t|j| j	r3qn6z|d |d W n( tjjyh   t|tjrft|sVY q| jrf|jdd   dkrfY qY nw q| jd||jfd qd S )N
__aenter__	__aexit__mixinr   )r   args)itemschecker_utils
safe_inferastroidUninferabler    r   AsyncFunctionDefr   r   basesAsyncGeneratorparentgetattr
exceptionsNotFoundErrorInstancehas_known_basesr   namelowerr"   )r   r   ctx_mgr_inferredr   r   r   visit_asyncwith9   s:   



zAsyncChecker.visit_asyncwith)__name__
__module____qualname__r   IAstroidChecker__implements__r8   msgsr   r+   check_messagesr   r/   r$   	AsyncWithr=   r   r   r   r   r      s&    r   c                 C   s   |  t|  dS )z-required method to auto register this checkerN)register_checkerr   )linterr   r   r   register_   s   rH   )__doc__r   r-   r   pylintr   r   r   pylint.checkersr+   pylint.checkers.utilsr   BaseCheckerr   rH   r   r   r   r   <module>   s   
H