o
    b                     @   s   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ	 ddl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)bases)
exceptions)checkers)utils)
interfaces)decorated_withc                   @   sd   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d Ze	
d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.Z
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.)ZE1700ZE1701c                 C   s   t | d| _dg| _d S )Nzignore-mixin-memberszcontextlib.asynccontextmanager)r   Zget_global_option_ignore_mixin_members_async_generators)self r   T/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/checkers/async.pyopen*   s   zAsyncChecker.openc                 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
   )node)	Znodes_of_classastroidYieldscopesysversion_info
isinstance	YieldFromadd_message)r   r   childr   r   r   visit_asyncfunctiondef0   s   
z#AsyncChecker.visit_asyncfunctiondefc              	   C   s   |j D ]a\}}t|}|d u s|tju rqt|tjr%t|j	| j
r$qn5z|d |d W n' tjyX   t|tjrVt|sFY q| jrV|jdd   dkrVY qY nw q| jd||jfd qd S )N
__aenter__	__aexit__Zmixinr   )r   args)itemschecker_utilsZ
safe_inferr   ZUninferabler   r   AsyncGeneratorr   parentr   getattrr   ZNotFoundErrorInstanceZhas_known_basesr   namelowerr   )r   r   Zctx_mgr_inferredr   r   r   visit_asyncwith8   s2   



zAsyncChecker.visit_asyncwithN)__name__
__module____qualname__r   ZIAstroidCheckerZ__implements__r+   Zmsgsr   r&   Zcheck_messagesr    r/   r   r   r   r   r      s&    
r   c                 C   s   |  t|  dS )z-required method to auto register this checkerN)Zregister_checkerr   )Zlinterr   r   r   registerZ   s   r3   )__doc__r   r   r   r   Zpylintr   Zpylint.checkersr   r&   r   Zpylint.checkers.utilsr   ZBaseCheckerr   r3   r   r   r   r   <module>   s   D