ó
'![c           @   sx   d  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 e j	 f d „  ƒ  YZ
 d	 „  Z d S(
   s!   Looks for overlapping exceptions.iÿÿÿÿN(   t
   interfaces(   t   checkers(   t   utils(   t   _annotated_unpack_infert   OverlappingExceptionsCheckerc           B   sN   e  Z d  Z e j Z d Z i d d 6Z d Z d	 Z	 e
 j d ƒ d „  ƒ Z RS(
   s    Checks for two or more exceptions in the same exception handler
    clause that are identical or parts of the same inheritance hierarchy
    (i.e. overlapping).s   overlap-excepts   Overlapping exceptions (%s)s   overlapping-excepts8   Used when exceptions in handler overlap or are identicalt   W0714iþÿÿÿc         C   s<  x5| j  D]*} | j d k r% q
 n  t | j t j ƒ r@ q
 n  y t t | j ƒ ƒ } Wn t j k
 rr q
 n Xg  } x¸| D]°\ } } | t j	 k r¡ q€ n  t | t j
 ƒ rÎ t j | ƒ rÎ | j } n  t | t j ƒ sæ q€ n  g  | j ƒ  D] } t | t j ƒ ró | ^ qó } x| D]û \ }	 }
 g  |
 j ƒ  D] } t | t j ƒ r7| ^ q7} | |
 k rœ|  j d d | j d d |	 j ƒ  | j ƒ  f ƒq|
 | k s´| | k r| | k rÆ| n |	 } |
 | k rÞ| n |	 } |  j d d | j d d | j ƒ  | j ƒ  f ƒqqW| | | f g 7} q€ Wq
 Wd S(   s   check for empty excepts   overlapping-exceptt   nodet   argss   %s and %s are the sames   %s is an ancestor class of %sN(   t   handlerst   typet   Nonet
   isinstancet   astroidt   BoolOpt   listR   t   InferenceErrort   YESt   InstanceR   t   inherit_from_std_ext   _proxiedt   ClassDeft	   ancestorst   add_messaget	   as_string(   t   selfR   t   handlert   excst   handled_in_clauset   partt   exct   anct   exc_ancestorst	   prev_partt   prev_exct   prev_exc_ancestorst   ancestort
   descendant(    (    sG   lib/python2.7/site-packages/pylint/extensions/overlapping_exceptions.pyt   visit_tryexcept   sL    			!(   s   Overlapping exceptions (%s)s   overlapping-excepts8   Used when exceptions in handler overlap or are identical(    (   t   __name__t
   __module__t   __doc__R    t   IAstroidCheckert   __implements__t   namet   msgst   priorityt   optionsR   t   check_messagesR%   (    (    (    sG   lib/python2.7/site-packages/pylint/extensions/overlapping_exceptions.pyR      s   	 
c         C   s   |  j  t |  ƒ ƒ d S(   s.   Required method to auto register this checker.N(   t   register_checkerR   (   t   linter(    (    sG   lib/python2.7/site-packages/pylint/extensions/overlapping_exceptions.pyt   registerO   s    (   R(   R   t   pylintR    R   t   pylint.checkersR   t   pylint.checkers.exceptionsR   t   BaseCheckerR   R2   (    (    (    sG   lib/python2.7/site-packages/pylint/extensions/overlapping_exceptions.pyt   <module>   s   >