ó
'![c           @   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 e j
 f d „  ƒ  YZ d	 „  Z d S(
   s=   Checker for anything related to the async protocol (PEP 492).iÿÿÿÿN(   t
   exceptions(   t   checkers(   t   utils(   t
   interfacest   AsyncCheckerc           B   sŠ   e  Z e j Z d  Z i d d d i d d 6f d 6d d	 d
 i d d 6f d 6Z d „  Z e j	 d ƒ d „  ƒ Z
 e j	 d	 ƒ d „  ƒ Z RS(   t   asyncs   Yield inside async functions   yield-inside-async-functionsQ   Used when an `yield` or `yield from` statement is found inside an async function.i   i   t
   minversiont   E1700sF   Async context manager '%s' doesn't implement __aenter__ and __aexit__.s   not-async-context-managersx   Used when an async context manager is used with an object that does not implement the async context management protocol.t   E1701c         C   s   t  j |  d ƒ |  _ d  S(   Ns   ignore-mixin-members(   R   t   get_global_optiont   _ignore_mixin_members(   t   self(    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyt   open$   s    c         C   sn   xg | j  t j ƒ D]S } | j ƒ  | k r t j d  d k sP t | t j ƒ r |  j d d | ƒq q Wd  S(   Ni   i   i   s   yield-inside-async-functiont   node(   i   i   (	   t   nodes_of_classt   astroidt   Yieldt   scopet   syst   version_infot
   isinstancet	   YieldFromt   add_message(   R   R   t   child(    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyt   visit_asyncfunctiondef'   s    %c         C   s  x| j  D]ý \ } } t j | ƒ } | d  k s
 | t j k rF q
 n  t | t j ƒ rè y | j d ƒ | j d ƒ Wq
 t	 j
 k
 rá t | t j ƒ rå t j | ƒ s° q
 n  |  j rÞ | j d j ƒ  d k rÛ q
 qÛ qÞ qå qè Xq
 n  |  j d d | d | j f ƒq
 Wd  S(   Nt
   __aenter__t	   __aexit__iûÿÿÿt   mixins   not-async-context-managerR   t   args(   t   itemst   checker_utilst
   safe_infert   NoneR   t   YESR   t   Instancet   getattrR    t   NotFoundErrort   has_known_basesR
   t   namet   lowerR   (   R   R   t   ctx_mgrt   _t   infered(    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyt   visit_asyncwith.   s$    	(   i   i   (   i   i   (   t   __name__t
   __module__R   t   IAstroidCheckert   __implements__R&   t   msgsR   R   t   check_messagesR   R+   (    (    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyR      s   		c         C   s   |  j  t |  ƒ ƒ d S(   s-   required method to auto register this checkerN(   t   register_checkerR   (   t   linter(    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyt   registerJ   s    (   t   __doc__R   R   R    t   pylintR   t   pylint.checkersR   R   R   t   BaseCheckerR   R4   (    (    (    s4   lib/python2.7/site-packages/pylint/checkers/async.pyt   <module>   s   6