
'![c           @   s  d  Z  d d l Z d d l Z d d l m Z m Z m Z m Z d d l m	 Z	 d d l
 m Z m Z m Z i d d d i d$ d 6f d 6d d d i d% d 6f d 6d& d 6d d d i d' d 6f d 6d d d i d( d 6f d 6d d d i d) d 6f d  6Z d! e	 f d"     YZ d#   Z d S(*   s+   check for new / old style related problems
iN(   t   IAstroidCheckert	   INFERENCEt   INFERENCE_FAILUREt   HIGH(   t   BaseChecker(   t   check_messagest   node_frame_classt   has_known_basess&   Use of __slots__ on an old style classs   slots-on-old-classs:   Used when an old style class uses the __slots__ attribute.i   i    t
   maxversiont   E1001s"   Use of super on an old style classs   super-on-old-classs4   Used when an old style class uses the super builtin.t   E1002s&   Bad first argument %r given to super()s   bad-super-callsp   Used when another argument than the current class is given as               first argument of the super builtin.t   E1003s   Missing argument to super()s   missing-super-argumentsF   Used when the super builtin didn't receive an                argument.t   E1004s'   Use of "property" on an old style classs   property-on-old-classs   Used when Pylint detect the use of the builtin "property"               on an old style class while this is relying on new style               classes features.t   W1001s   Old-style class defined.s   old-style-classst   Used when a class is defined that does not inherit from another class and does not inherit explicitly from "object".t   C1001t   NewStyleConflictCheckerc           B   s}   e  Z d  Z e f Z d Z e Z d Z d Z	 e
 d d  d    Z e
 d  d    Z e
 d d	 d
  d    Z e Z RS(   s   checks for usage of new style capabilities on old style classes and
    other new/old styles conflicts problems
    * use of property, __slots__, super
    * "super" usage
    t   newstyleis   slots-on-old-classs   old-style-classc         C   s   d | k rJ | j  rJ t |  r( t n t } |  j d d | d | n  | j r | j d k r | j   r |  j d d | d t n  d S(   sV    Check __slots__ in old style classes and old
        style class definition.
        t	   __slots__s   slots-on-old-classt   nodet
   confidencet   classs   old-style-classN(	   R   R   R   R   t   add_messaget   basest   typet	   metaclassR   (   t   selfR   R   (    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyt   visit_classdefM   s    
&s   property-on-old-classc         C   s   | j  j   } t | t j  r | j r t | j t j  r t |  rR t	 n t
 } | j j } | d k r |  j d d | d | q n  d S(   s   check property usaget   propertys   property-on-old-classR   R   N(   t   parentt   framet
   isinstancet   astroidt   ClassDefR   t   funct   NameR   R   R   t   nameR   (   R   R   R   R   R#   (    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyt
   visit_call_   s    
s   super-on-old-classs   bad-super-calls   missing-super-argumentc   	      C   s  | j    s d S| j j   } x| j t j  D]} t |  t |  k rV q2 n  | j } t | t j	  sw q2 n  | j
 } t | t j  o t | j t j  o | j j d k s q2 n  | j r t |  r |  j d d | q2 | j s&t j d d k rq2 q&|  j d d | q2 n  | j d } t | t j  rt | j t j  r| j j d k r|  j d	 d | d
 d q2 n  t | j  d k rt | j d t j  r| j d j d k rt | t j	  r| j d k r|  j d	 d | d
 d q2 n  y) | j o4t | j d j   d  } Wn t j k
 rQq2 n X| | k	 r2 d } | rv| j } n2 | j rt | j d d  r| j d j } n  | r|  j d	 d | d
 | f qq2 q2 Wd S(   s   check use of superNt   supers   super-on-old-classR   i    i   s   missing-super-argumentR   s   bad-super-callt   argsi   i   R   t	   __class__s   self.__class__R#   (   R   (   s   self.__class__(   t	   is_methodR   R   t   nodes_of_classR   t   CallR   R!   R   t	   Attributet   exprR"   R#   R   R   R   R&   t   syst   version_infot   lent   attrnamet   nextt   infert   Nonet   InferenceErrort   hasattr(	   R   R   t   klasst   stmtR,   t   callt   arg0t   supclsR#   (    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyt   visit_functiondefm   s\    			)(    (   t   __name__t
   __module__t   __doc__R    t   __implements__R#   t   MSGSt   msgst   priorityt   optionsR   R   R$   R;   t   visit_asyncfunctiondef(    (    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyR   <   s   	Hc         C   s   |  j  t |    d S(   s.   required method to auto register this checker N(   t   register_checkerR   (   t   linter(    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyt   register   s    (   i   i    (   i   i    (   s&   Bad first argument %r given to super()s   bad-super-callsp   Used when another argument than the current class is given as               first argument of the super builtin.(   i   i    (   i   i    (   i   i    (   R>   R-   R   t   pylint.interfacesR    R   R   R   t   pylint.checkersR   t   pylint.checkers.utilsR   R   R   R@   R   RG   (    (    (    s7   lib/python2.7/site-packages/pylint/checkers/newstyle.pyt   <module>   s>   "  |