
'![c        
   @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l 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 d d l j Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ i e d 6e d 6e d 6e d 6e d 6Z  e j! d  Z" d Z# d d f Z$ e$ e# f f Z% e& d  d! d" d# d$ d% f  Z' e j( e j) e j* e j+ f Z, d& Z- e j. j/ j0 Z1 d' e1 Z2 e j3 d( d( f k Z4 e j3 d( d) f k Z5 e j3 d( d* f k Z6 d+ d, h Z7 e8 e g  d- d. d/ f D] Z9 d0 j: e1 e9 g  ^ qd1 d2 d3 g   Z; i d4 d5 6d6 d7 6d5 d4 6d7 d6 6Z< d8   Z= d9   Z> d:   Z? d;   Z@ d<   ZA d=   ZB e j3 d( d) f k  r7d> ZC n d? ZC d@   ZD eE dA  ZF dB   ZG dC   ZH dD   ZI dE e jJ f dF     YZK dG eK f dH     YZL dI eK f dJ     YZM dK dL dM dN dO dP dQ dR dS dT h
 ZN i
 dK dK 6dU dL 6dM dM 6dN dN 6dO dO 6dV dP 6dQ dQ 6dR dR 6dW dS 6dX dT 6ZO i
 d dK 6d dL 6d dM 6d dN 6d dO 6d dP 6d dQ 6d dR 6d dS 6d dT 6ZP dY   ZQ dZ eK f d[     YZR d\ eK f d]     YZS d^ eK f d_     YZT d` eK f da     YZU db   ZV dc eK f dd     YZW de   ZX d S(f   s   basic checker for Python codeiN(   t   zip(   t   checkers(   t
   exceptions(   t
   interfaces(   t   utils(   t	   reporters(   t   get_node_last_lineno(   t   nodest   NamingStylec           B   s;   e  Z d Z d Z d Z d Z d Z d Z e	 d     Z
 RS(   c         C   sl   i
 |  j  d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d 6|  j d	 6|  j d
 6| S(   Nt   modulet   constt   classt   functiont   methodt   attrt   argumentt   variablet   class_attributet	   inlinevar(   t   MOD_NAME_RGXt   CONST_NAME_RGXt   CLASS_NAME_RGXt   DEFAULT_NAME_RGXt   CLASS_ATTRIBUTE_RGXt   COMP_VAR_RGX(   t   clst	   name_type(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt	   get_regexB   s    









N(   t   __name__t
   __module__t   NoneR   R   R   R   R   R   t   classmethodR   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   6   s   t   SnakeCaseStylec           B   sb   e  Z e j d   Z e j d  Z e j d  Z e j d  Z e j d  Z e j d  Z	 RS(   s   [a-z_][a-z0-9_]+$s   ([a-z_][a-z0-9_]*)$s   (([a-z_][a-z0-9_]*)|(__.*__))$s   [a-z_][a-z0-9_]*$s>   (([a-z_][a-z0-9_]{2,30})|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$s#   (([a-z_][a-z0-9_]{2,30}|(__.*__)))$(
   R   R   t   ret   compileR   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    R   s   t   CamelCaseStylec           B   sb   e  Z e j d   Z e j d  Z e j d  Z e j d  Z e j d  Z e j d  Z	 RS(   s   [a-z_][a-zA-Z0-9]+$s   ([a-z_][a-zA-Z0-9]*)$s    (([a-z_][A-Za-z0-9]*)|(__.*__))$s   [a-z_][A-Za-z0-9]*$s5   (([a-z_][a-zA-Z0-9]{2,30})|(__[a-z][a-zA-Z0-9_]+__))$s#   ([a-z_][A-Za-z0-9]{2,30}|(__.*__))$(
   R   R   R!   R"   R   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR#   [   s   t   PascalCaseStylec           B   sb   e  Z e j d   Z e j d   Z e j d  Z e j d   Z e j d  Z e j d  Z	 RS(   s   [A-Z_][a-zA-Z0-9]+$s    (([A-Z_][A-Za-z0-9]*)|(__.*__))$s2   [A-Z_][a-zA-Z0-9]{2,30}$|(__[a-z][a-zA-Z0-9_]+__)$s   [A-Z_][a-zA-Z0-9]{2,30}$(
   R   R   R!   R"   R   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR$   d   s   t   UpperCaseStylec           B   sb   e  Z e j d   Z e j d   Z e j d  Z e j d   Z e j d  Z e j d  Z	 RS(   s   [A-Z_][A-Z0-9_]+$s   (([A-Z_][A-Z0-9_]*)|(__.*__))$s1   ([A-Z_][A-Z0-9_]{2,30})|(__[a-z][a-zA-Z0-9_]+__)$s   [A-Z_][A-Z0-9_]{2,30}$(
   R   R   R!   R"   R   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR%   m   s   t   AnyStylec           B   s   e  Z e d     Z RS(   c         C   s   t  j d  S(   Ns   .*(   R!   R"   (   R   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   w   s    (   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR&   v   s   t
   snake_caset	   camelCaset
   PascalCaset
   UPPER_CASEt   anys   ^_t   __reversed__t   __getitem__t   __len__t   iss   is nots   ==s   !=t   ins   not ins   unittest.cases   %s.typei   i    i   t   exemptt   ignoret   sett   dictt   listt   .s   set()s   {}s   []t   >t   <s   >=s   <=c         C   s   |  } x) | r1 t  | j t j  r1 | j } q	 W| sO t j | j t  rS t S| j j } xl | j t j	 t j
 f  D]O } xF | j D]; \ } } | r | |  j k r t Sq | |  j k r t Sq Wq{ Wt S(   s    Detect that the given node (AssignName) is inside an
    exception handler and redefines an import from the tryexcept body.
    Returns True if the node redefines an import, False otherwise.
    (   t
   isinstancet   parentt   astroidt   ExceptHandlerR   t   error_of_typet   ImportErrort   Falset   nodes_of_classt
   ImportFromt   Importt   namest   namet   True(   t   nodet   currentt	   try_blockt   import_nodeRD   t   alias(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _redefines_import   s    "c         C   sZ   |  j  } xJ | d k	 rU t | t j t j t j t j t j f  rI t	 S| j  } q Wt
 S(   s4   return True if the node is inside a kind of for loopN(   R:   R   R9   R;   t   Fort   ListCompt   SetCompt   DictCompt   GeneratorExpRE   R?   (   RF   R:   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   in_loop   s    	c         C   sP   xI |  D]A } t  | t t f  r8 t | |  rH t Sq | | k r t Sq Wt S(   sU   return true if the object is an element of <nested_list> or of a nested
    list
    (   R9   R5   t   tuplet   in_nested_listRE   R?   (   t   nested_listt   objt   elmt(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRS      s    c         C   sg   t  j t  j f } |  j } xE t | |  sF |  t | d g   k rb | j } | d k r Pq q W| S(   s   
    Returns the loop node that holds the break node in arguments.

    Args:
        break_node (astroid.Break): the break node of interest.

    Returns:
        astroid.For or astroid.While: the loop node holding the break node.
    t   orelseN(   R;   RL   t   WhileR:   R9   t   getattrR   (   t
   break_nodet
   loop_nodesR:   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _get_break_loop_node   s    
	+	c            s   t  j t  j f } t  j t  j f } g  |  j | d | D] } | |  k r: | ^ q:   t   f d   |  j t  j d | D  S(   s   
    Returns true if a loop may ends up in a break statement.

    Args:
        loop (astroid.For, astroid.While): the loop node inspected.

    Returns:
        bool: True if the loop may ends up in a break statement, False otherwise.
    t
   skip_klassc         3   s'   |  ] } t  |    k r | Vq d  S(   N(   R\   (   t   .0t   _node(   t   inner_loop_nodes(    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>   s    (   R;   RL   RX   t   FunctionDeft   ClassDefR@   R+   t   Break(   t   loopR[   t   definition_nodesR_   (    (   R`   s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _loop_exits_early   s    
c         C   sC   |  d  k	 oB |  j d  k	 oB |  j t k oB | d k pB | t j k S(   NR   (   R   t	   lastgroupt   EXEMPT_NAME_CATEGORIESR   t   INFERENCE_FAILURE(   t   matcht	   node_typet
   confidence(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _is_multi_naming_match   s    s   __builtin__.propertys   builtins.propertyc         C   s[   t  t f  } t    } |  d k	 rQ | j |  j  | j d   |  j D  n  | | f S(   s   Returns a tuple of property classes and names.

    Property classes are fully qualified, such as 'abc.abstractproperty' and
    property names are the actual names, such as 'abstract_property'.
    c         s   s%   |  ] } | j  d  d  d Vq d S(   R6   i   iN(   t   rsplit(   R^   t   prop(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>  s   N(   R3   t   BUILTIN_PROPERTYR   t   updatet   property_classes(   t   configRr   t   property_names(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _get_properties  s    	c         C   s   t  |  \ } } |  j   s" d S|  j r: |  j j } n g  } x | D] } t | t j  s t | t j  r | j | k r t	 j
 |  } | r | j   | k r d SqG t | t j  rG | j d k rG d SqG Wd S(   s\  Determine the name type whose regex the a function's name should match.

    :param node: A function node.
    :type node: astroid.node_classes.NodeNG
    :param config: Configuration from which to pull additional property classes.
    :type config: :class:`optparse.Values`

    :returns: One of ('function', 'method', 'attr')
    :rtype: str
    R   R   t   settert   deleterR   (   Rv   Rw   (   Ru   t	   is_methodt
   decoratorsR   R9   R;   t   Namet	   Attributet   attrnameR   t
   safe_infert   qname(   RF   Rs   Rr   Rt   Ry   t	   decoratort   infered(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _determine_function_name_type  s"    	c         C   s   t  t j |    d k S(   s   
    Determine if the given `node` has abstract methods.

    The methods should be made abstract by decorating them
    with `abc` decorators.
    i    (   t   lenR   t   unimplemented_abstract_methods(   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _has_abstract_methods3  s    c      
   C   s  i  } x d D] } y | | } Wn t  k
 r@ t j    n Xi  | | <| d k r y6 | | d | } | d | } d | | | d	 <Wn t  k
 r d
 | | d	 <n Xy, | d | d | } d | | | d <Wq t  k
 r d
 | | d <q Xq q Wd } x d D] } | | }	 | j | d  }
 |
 d k	 rTt j |
 |	  } n d \ }
 } | | t |	  t |
  | | | j d	 d  | | j d d  f 7} qW|  j t	 j
 d | d d d d   d S(   sy   make a report of

    * percentage of different types documented
    * percentage of different types with a bad name
    R	   R   R   R   i    t   undocumented_g      Y@s   %.2ft   percent_documentedt   NCt   badname_t   percent_badnamet   typet   numbers
   old numbert
   differences   %documenteds   %badnamet   0t   childrent   colsi   t   rheadersi   N(   R	   R   R   R   (   R   R   s
   old numberR   s   %documenteds   %badname(   R	   R   R   R   (   R   R   (   t   KeyErrorR   t   EmptyReportErrort   getR   R   t   diff_stringt   strt   appendt   reporter_nodest   Table(   t   sectt   statst	   old_statst
   nice_statsRk   t   totalt
   documentedt   percentt   linest   newt   oldt   diff_str(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   report_by_type_stats=  s>    
 
c         C   s[   |  j  rW xK |  j  j D]: } t | t j  r t | j d d  |  j k r t	 Sq Wn  t
 S(   s   return True if the object is a method redefined via decorator.

    For example:
        @property
        def x(self): return self._x
        @x.setter
        def x(self, value): self._x = value
    RD   N(   Ry   R   R9   R;   R{   RY   t   exprR   RD   RE   R?   (   RF   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   redefined_by_decoratorf  s    		t   _BasicCheckerc           B   s   e  Z e j Z d  Z RS(   t   basic(   R   R   R   t   IAstroidCheckert   __implements__RD   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   w  s   	t   BasicErrorCheckerc           B   s  e  Z i dc d 6dd d 6de d 6df d 6dg d 6dh d 6d d d i di d 6f d 6dj d! 6dk d% 6dl d) 6dm d- 6d. d/ d0 i dn d2 6f d3 6d4 d5 d6 i do d2 6f d7 6d8 d9 d: i dp d2 6f d; 6d< d= d> i dq d2 6f d? 6dr dC 6dD dE dF i ds d2 6f dG 6dH dI dJ i dt d2 6f dL 6Z e j d	  dM    Z e j d/ d5  dN    Z e j d9  dO    Z e j d d d	 d d# d= dI  dP    Z e Z	 dQ   Z
 dR   Z e j d  dS    Z e j d  dT    Z e j d  dU    Z e j d dA  dV    Z e j d  dW    Z e j d+  dX    Z e j d+  dY    Z e j d  dZ    Z d[   Z e j dE  d\    Z e j d'  d]    Z d^   Z d_   Z d`   Z da   Z db   Z RS(u   s   __init__ method is a generators   init-is-generators^   Used when the special class method __init__ is turned into a generator by a yield in its body.t   E0100s   Explicit return in __init__s   return-in-initsI   Used when the special class method __init__ has an explicit return value.t   E0101s   %s already defined line %ss   function-redefineds3   Used when a function / class / method is redefined.t   E0102s   %r not properly in loops   not-in-loops=   Used when break or continue keywords are used outside a loop.t   E0103s   Return outside functions   return-outside-functionsE   Used when a "return" statement is found outside a function or method.t   E0104s   Yield outside functions   yield-outside-functionsD   Used when a "yield" statement is found outside a function or method.t   E0105s%   Return with argument inside generators   return-arg-in-generators   Used when a "return" statement with an argument is found outside in a generator function or method (e.g. with some "yield" statements).i   t
   maxversiont   E0106s#   Use of the non-existent %s operators   nonexistent-operatorsy   Used when you attempt to use the C-style pre-increment orpre-decrement operator -- and ++, which doesn't exist in Python.t   E0107s1   Duplicate argument name %s in function definitions   duplicate-argument-namesC   Duplicate argument names in function definitions are syntax errors.t   E0108s4   Abstract class %r with abstract methods instantiateds   abstract-class-instantiatedse   Used when an abstract class with `abc.ABCMeta` as metaclass has abstract methods and is instantiated.t   E0110s-   Else clause on loop without a break statements   useless-else-on-loops   Loops should only have an else clause if they can exit early with a break statement, otherwise the statements under else should be on the same scope as the loop itself.t   W0120s.   More than one starred expression in assignments   too-many-star-expressionssh   Emitted when there are more than one starred expressions (`*x`) in an assignment. This is a SyntaxError.i    t
   minversiont   E0112s4   Starred assignment target must be in a list or tuples   invalid-star-assignment-targetsF   Emitted when a star expression is used as a starred assignment target.t   E0113s4   Can use starred expression only in assignment targets   star-needs-assignment-targetsC   Emitted when a star expression is not used in an assignment target.t   E0114s   Name %r is nonlocal and globals   nonlocal-and-globals0   Emitted when a name is both nonlocal and global.t   E0115s0   'continue' not supported inside 'finally' clauses   continue-in-finallys]   Emitted when the `continue` keyword is found inside a finally clause, which is a SyntaxError.t   E0116s&   nonlocal name %s found without bindings   nonlocal-without-bindings^   Emitted when a nonlocal variable does not have an attached name somewhere in the parent scopest   E0117s+   Name %r is used prior to global declarations   used-prior-global-declarationsc   Emitted when a name is used prior a global declaration, which results in an error since Python 3.6.i   t   E0118c         C   s   |  j  d |  d  S(   NR   (   t   _check_redefinition(   t   selfRF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_classdef  s    c         C   sz   t  | j d j t j   } t |  d k rG |  j d d | n  t | j d t j  rv |  j d d | n  d  S(   Ni    i   s   too-many-star-expressionsRF   s   invalid-star-assignment-target(   R5   t   targetsR@   R;   t   StarredR   t   add_messageR9   (   R   RF   t   starred(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_assign  s
    c         C   s   t  | j t j  r d St rM t  | j t j t j t j t j f  rM d S| j	   } t  | t j
  so d S| j | k s | j j |  r |  j d d | n  d S(   s@   Check that a Starred expression is used in an assignment target.Ns   star-needs-assignment-targetRF   (   R9   R:   R;   t   Callt   PY35t   Listt   Tuplet   Sett   Dictt	   statementt   Assignt   valuet	   parent_ofR   (   R   RF   t   stmt(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_starred  s    !c         C   s  |  j  |  |  j |  t |  r\ t j |  r\ |  j | j   rO d pR d |  n  | j t j	 d t j
 t j f } | j   r| j d k r| j   r |  j d d | qwg  | D] } | j ^ q } t d   | D  rw|  j d d | qwno | j   rwt swxW | D]L } t | j t j  r!| j j d  k	 r!|  j d	 d | d
 | j q!q!Wqwn  t   } xL | j   D]> } | | k r|  j d d | d | f q| j |  qWd  S(   NR   R   R]   t   __init__s   init-is-generatorRF   c         s   s$   |  ] } t  j |  s | Vq d  S(   N(   R   t   is_none(   R^   t   v(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>  s    s   return-in-inits   return-arg-in-generatort   lines   duplicate-argument-namet   args(   t   _check_nonlocal_and_globalt   _check_name_used_prior_globalR   R   t(   is_registered_in_singledispatch_functionR   Rx   R@   R;   t   ReturnRa   Rb   RD   t   is_generatorR   R   R+   t   PY33R9   t   ConstR   t
   fromlinenoR3   t   argnamest   add(   R   RF   t   returnst   rt   valuest   retnodeR   RD   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_functiondef  s4    %	c            s     f d     j  t j  D } x   j  t j  D] } | j     k	 rS q5 n  | j } | j |  } | sw q5 n  | j } | r5 | | j k r5 |  j d d | d | f q5 q5 Wd  S(   Nc            s;   i  |  ]1 } | j  D]! } | j     k r | |  q q S(    (   RC   t   scope(   R^   t   childRD   (   RF   (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys
   <dictcomp>  s   	s   used-prior-global-declarationRF   R   (	   R@   R;   t   GlobalRz   R   RD   R   R   R   (   R   RF   t   scope_globalst	   node_nameRD   t   corresponding_globalt   global_lineno(    (   RF   s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    		c            s     f d    t  j j } t |  f d     j t j  D   } t |  f d     j t j  D   } x3 | j |  D]" } |  j	 d d | f d   q Wd S(   s.   Check that a name is both nonlocal and global.c            s   |  j      k S(   N(   R   (   RG   (   RF   (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   same_scope2  s    c         3   s$   |  ] }   |  r | j  Vq d  S(   N(   RC   (   R^   R   (   R   (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>7  s    c         3   s$   |  ] }   |  r | j  Vq d  S(   N(   RC   (   R^   R   (   R   (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>:  s    s   nonlocal-and-globalR   RF   N(
   t	   itertoolst   chaint   from_iterableR3   R@   R;   t   NonlocalR   t   intersectionR   (   R   RF   t	   from_itert	   nonlocalst   global_varsRD   (    (   RF   R   s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   0  s    ((c         C   s2   t  | j   t j  s. |  j d d | n  d  S(   Ns   return-outside-functionRF   (   R9   t   frameR;   Ra   R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_return@  s    c         C   s   |  j  |  d  S(   N(   t   _check_yield_outside_func(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_yieldE  s    c         C   s   |  j  |  d  S(   N(   R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_yieldfromI  s    c         C   s   |  j  | d  d  S(   Nt   continue(   t   _check_in_loop(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_continueM  s    c         C   s   |  j  | d  d  S(   Nt   break(   R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_breakQ  s    c         C   s   |  j  |  d  S(   N(   t   _check_else_on_loop(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt	   visit_forU  s    c         C   s   |  j  |  d  S(   N(   R  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_whileY  s    c         C   s`   | j  d k r\ t | j t j  r\ | j j  | j  k r\ |  j d d | d | j  d n  d S(   s9   check use of the non-existent ++ and -- operator operators   +-s   nonexistent-operatorRF   R   i   N(   t   opR9   t   operandR;   t   UnaryOpR   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_unaryop]  s    c         C   s   | j    } x} t r | j d  k r( Pn  t | t j t j f  sc |  j d d | f d | d  S| | j	 k r | j j    } q n  d  SWt | t j  s |  j d d | f d | n  d  S(   Ns   nonlocal-without-bindingR   RF   (
   R   RE   R:   R   R9   R;   Rb   Ra   R   t   locals(   R   RF   RD   t   current_scope(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _check_nonlocal_without_bindinge  s    	c         C   s(   x! | j  D] } |  j | |  q
 Wd  S(   N(   RC   R  (   R   RF   RD   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_nonlocalz  s    c         C   sJ   y. x' | j  j   D] } |  j | |  q WWn t j k
 rE d SXd S(   sS    Check instantiating abstract class with
        abc.ABCMeta as metaclass.
        N(   t   funct   infert!   _check_inferred_class_is_abstractR;   t   InferenceError(   R   RF   t   inferred(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_call  s
    c         C   s   t  | t j  s d  St j |  } | | k r5 d  S| j   } t |  } | d  k r xO | j   D]A } | j	   d k rf | rf |  j
 d d | j f d | Pqf qf Wd  S| j	   d k r | r |  j
 d d | j f d | n  d  S(   Ns   abc.ABCs   abstract-class-instantiatedR   RF   s   abc.ABCMeta(   R9   R;   Rb   R   t   node_frame_classt	   metaclassR   R   t	   ancestorsR~   R   RD   (   R   R   RF   t   klassR  t   abstract_methodst   ancestor(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s&    c         C   s;   t  | j   t j t j f  s7 |  j d d | n  d  S(   Ns   yield-outside-functionRF   (   R9   R   R;   Ra   t   LambdaR   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    !c         C   sD   | j  r@ t |  r@ |  j d d | d | j  d j d n  d S(   s>   Check that any loop with an else clause has a break statement.s   useless-else-on-loopRF   R   i    i   N(   RW   Rf   R   t   lineno(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s    c         C   s   | j  } x | r t | t j t j f  rC | | j k rC d Sn  t | t j t j f  rb Pn  t | t j  r | | j	 k r t | t j
  r |  j d d | n  | j  } q W|  j d d | d | d S(   s/   check that a node is inside a for or while loopNs   continue-in-finallyRF   s   not-in-loopR   (   R:   R9   R;   RL   RX   RW   Rb   Ra   t
   TryFinallyt	   finalbodyt   ContinueR   (   R   RF   R   R_   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    		c         C   s   | j  j   | j } | | k	 r t j | |  r t j |  d d d } | ri | j | j  ri d S|  j	 d d | d | | j
 f n  d S(   s:   check for redefinition of a function / method / class names   dummy-variables-rgxt   defaultNs   function-redefinedRF   R   (   R:   R   RD   R;   t   are_exclusivet
   lint_utilst   get_global_optionR   Rj   R   R   (   R   t	   redeftypeRF   t   defined_selft   dummy_variables_rgx(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    (   s   __init__ method is a generators   init-is-generators^   Used when the special class method __init__ is turned into a generator by a yield in its body.(   s   Explicit return in __init__s   return-in-initsI   Used when the special class method __init__ has an explicit return value.(   s   %s already defined line %ss   function-redefineds3   Used when a function / class / method is redefined.(   s   %r not properly in loops   not-in-loops=   Used when break or continue keywords are used outside a loop.(   s   Return outside functions   return-outside-functionsE   Used when a "return" statement is found outside a function or method.(   s   Yield outside functions   yield-outside-functionsD   Used when a "yield" statement is found outside a function or method.(   i   i   (   s#   Use of the non-existent %s operators   nonexistent-operatorsy   Used when you attempt to use the C-style pre-increment orpre-decrement operator -- and ++, which doesn't exist in Python.(   s1   Duplicate argument name %s in function definitions   duplicate-argument-namesC   Duplicate argument names in function definitions are syntax errors.(   s4   Abstract class %r with abstract methods instantiateds   abstract-class-instantiatedse   Used when an abstract class with `abc.ABCMeta` as metaclass has abstract methods and is instantiated.(   s-   Else clause on loop without a break statements   useless-else-on-loops   Loops should only have an else clause if they can exit early with a break statement, otherwise the statements under else should be on the same scope as the loop itself.(   i   i    (   i   i    (   i   i    (   i   i    (   s0   'continue' not supported inside 'finally' clauses   continue-in-finallys]   Emitted when the `continue` keyword is found inside a finally clause, which is a SyntaxError.(   i   i    (   i   i   (   R   R   t   msgsR   t   check_messagesR   R   R   R   t   visit_asyncfunctiondefR   R   R   R   R   R   R  R  R  R  R  R  R  R  R   R  R   R   (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   |  s                         	
#								t   BasicCheckerc           B   s  e  Z d  Z e j Z d Z i dX d 6dY d	 6dZ d 6d[ d 6d\ d 6d] d 6d^ d 6d_ d! 6d` d% 6da d) 6db d- 6dc d1 6dd d5 6de d9 6Z d: d; e f f Z	 d<   Z
 d=   Z e j d3  d>    Z e j d3  d?    Z e j d3  d@    Z dA   Z dB   Z dC   Z e j d d d  dD    Z e dE    Z e dF    Z e j d  dG    Z e j d  dH    Z e Z dI   Z e j d d'  dJ    Z e j d  dK    Z e j d d'  dL    Z e j d  dM    Z e j d  dN    Z  e j d# d d7  dO    Z! e j d+  dP    Z" e j d  dQ    Z# dR   Z$ dS   Z% dT   Z& df dU  Z' dV   Z( e j d/  dW    Z) RS(g   s&  checks for :
    * doc strings
    * number of arguments, local variables, branches, returns and statements in
functions, methods
    * required module attributes
    * dangerous default values as arguments
    * redefinition of function / method / class
    * uses of the global statement
    R   s   Unreachable codet   unreachablesb   Used when there is some code behind a "return" or "raise" statement, which will never be accessed.t   W0101s&   Dangerous default value %s as arguments   dangerous-default-values_   Used when a mutable value as list or dictionary is detected in a default value for an argument.t   W0102s!   Statement seems to have no effects   pointless-statementsE   Used when a statement doesn't have (or at least seems to) any effect.t   W0104s   String statement has no effects   pointless-string-statements   Used when a string is used as a statement (which of course has no effect). This is a particular case of W0104 with its own message so you can easily disable it if you're using those strings as documentation, instead of comments.t   W0105s&   Expression "%s" is assigned to nothings   expression-not-assignedsq   Used when an expression that is not a function call is assigned to nothing. Probably something else was intended.t   W0106s   Lambda may not be necessarys   unnecessary-lambdas   Used when the body of a lambda expression is a function call on the same argument list as the lambda itself; such lambda expressions are in all but a few cases replaceable with the function being called in the body of the lambda.t   W0108s   Duplicate key %r in dictionarys   duplicate-keysD   Used when a dictionary expression binds the same key multiple times.t   W0109s   Use of execs	   exec-useds~   Used when you use the "exec" statement (function for Python 3), to discourage its usage. That doesn't mean you cannot use it !t   W0122s   Use of evals	   eval-useds   Used when you use the "eval" function, to discourage its usage. Consider using `ast.literal_eval` for safely evaluating strings containing Python expressions from untrusted sources. t   W0123s3   %s statement in finally block may swallow exceptions   lost-exceptions   Used when a break or a return statement is found inside the finally clause of a try...finally block: the exceptions raised in the try clause will be silently swallowed instead of being re-raised.t   W0150s5   Assert called on a 2-uple. Did you mean 'assert x,y'?s   assert-on-tuples   A call of assert on a tuple will always evaluate to true if the tuple is not empty, and will always evaluate to false if it is.t   W0199s?   Following "as" with another context manager looks like a tuple.s   confusing-with-statements2  Emitted when a `with` statement component returns multiple values and uses name binding with `as` only for a part of those values, as in with ctx() as a, b. This can be misleading, since it's not clear if the context manager returns a tuple or if the node without a name binding is another context manager.t   W0124s3   Using a conditional statement with a constant values   using-constant-tests   Emitted when a conditional statement (If or ternary if) uses a constant value for its test. This might not be what the user intended to do.t   W0125s/   The first reversed() argument is not a sequences   bad-reversed-sequences   Used when the first argument to reversed() builtin isn't a sequence (does not implement __reversed__, nor __getitem__ and __len__t   E0111t   RP0101s   Statistics by typec         C   s&   t  j |  |  d  |  _ d  |  _ d  S(   N(   R   R   R   R   t   _tryfinallys(   R   t   linter(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   /  s    	c      	   C   s7   g  |  _  |  j j d d d d d d d d  |  _ d S(   s2   initialize visit variables and statistics
        R	   i    R   R   t   class_N(   R9  R:  t	   add_statsR   (   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   open4  s    	c         C   s   |  j  | | j  d  S(   N(   t   _check_using_constant_testt   test(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_if;  s    c         C   s   |  j  | | j  d  S(   N(   R>  R?  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_ifexp?  s    c         C   s4   | j  r0 x$ | j  D] } |  j | |  q Wn  d  S(   N(   t   ifsR>  (   R   RF   t   if_test(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_comprehensionC  s    	c      	   C   s   t  j t  j j t  j t  j t  j t  j j t  j	 t  j
 t  j f	 } t  j t  j t  j f } t  j t  j t  j t  j t  j t  j f } d  } t | t  j f | |  } t | |  s t j |  } n  | s t | |  r |  j d d | n  d  S(   Ns   using-constant-testRF   (   R;   t   Modulet   scoped_nodesRP   R  Ra   Rb   t   basest	   Generatort   UnboundMethodt   BoundMethodR   R   R   R{   R   t   BinOpt   BoolOpR  t	   SubscriptR   R9   R   R   R}   R   (   R   RF   R?  t   const_nodest   structst   except_nodesR  t   emit(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR>  I  s    	c         C   s   |  j  d c d 7<d S(   s<   check module name, docstring and required arguments
        R	   i   N(   R   (   R   t   _(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_modulec  s    c         C   s   |  j  d c d 7<d S(   sW   check module name, docstring and redefinition
        increment branch counter
        R   i   N(   R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   h  s    c         C   s{  | j  } t | t j  r t | j  t j  r | j   } t | t j t j t j	 f  r t | t j	  r | j
 d k r q | j   } | d k	 r | j   | k r t | t j  r d Sn  |  j d d | d St | t j t j t j f  s&t | j t j  r*| j j | g k r*d St | j t j   rd|  j d d | d | j   n |  j d d | d S(   s3   check for various kind of statements without effectR   Ns   pointless-string-statementRF   s   expression-not-assignedR   s   pointless-statement(   R   R9   R;   R   t   sixt   string_typesR   Rb   RE  Ra   RD   t   previous_siblingR   R   R   t   Yieldt   AwaitR   R:   t	   TryExceptt   bodyR+   R@   t	   as_string(   R   RF   R   R   t   sibling(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_exprn  s*    	!!!c         c   sd   x] | D]U } t  | t j  rW t  | j t j  r\ | j j |  j j k r\ | Vq\ q | Vq Wd  S(   N(   R9   R;   R   R   Rz   RD   R   t   vararg(   RF   t	   call_argst   arg(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _filter_vararg  s    c         C   sQ   |  s
 t  Sx@ |  D]8 } t | j t j  rE | j j | k rI t  Sq t  Sq Wt S(   N(   RE   R9   R   R;   Rz   RD   R?   (   R   t   variadic_nameR`  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _has_variadic_argument  s    c         C   s  | j  j r d S| j } t | t j  s/ d St | j j t j  rf t | j j j t j  rf d St	 | j  j   } t	 |  j
 | | j    } | j  j r |  j | j | j  j  r d Sn | j s | j r d S| j  j r|  j | j | j  j  rd Sn | j rd St |  t |  k r.d SxI t | |  D]8 \ } } t | t j  s`d S| j | j k r>d Sq>W|  j d d | j d | d S(   s6   check whether or not the lambda is suspicious
        Ns   unnecessary-lambdaR   RF   (   R   t   defaultsRZ  R9   R;   R   R  R{   R   R5   Ra  t   kwargRc  t   kwargst   keywordsR^  t   starargsR   R    Rz   RD   R   R   (   R   RF   t   callt   ordinary_argst   new_call_argsR`  t
   passed_arg(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_lambda  s:    		c         C   s6   |  j  | j   r d p d c d 7<|  j |  d S(   sd   check function name, docstring, arguments, redefinition,
        variable names, max locals
        R   R   i   N(   R   Rx   t   _check_dangerous_default(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    %c         C   s\  d   } xL| j  j D]>} y t | j    } Wn t j k
 rK q n Xt | t j  r | j   t	 k r | | k r t	 | j   } n t | t j  s | |  r| |  r | j
   } q5t | t j  r d | j | j   f } q5d | j   | j   f } n  d | j   t	 | j   f } |  j d d | d | f q q Wd  S(   Nc         S   s   t  |  t j t j t j f  S(   N(   R9   R;   R   R   R   (   t   n(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   <lambda>  s   s	   %s() (%s)s   %s (%s)s   dangerous-default-valueRF   R   (   R   Rd  t   nextR  R;   R  R9   t   InstanceR~   t   DEFAULT_ARGUMENT_SYMBOLSt   pytypeR   RD   R[  R   (   R   RF   t   is_iterableR  R   t   msg(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRn    s*    	c         C   s*   |  j  |  |  j | d t j f  d S(   s   1 - check is the node has a right sibling (if so, that's some
        unreachable code)
        2 - check is the node is inside the finally clause of a try...finally
        block
        t   returnN(   t   _check_unreachablet   _check_not_in_finallyR;   Ra   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    c         C   s   |  j  |  d S(   s\   check is the node has a right sibling (if so, that's some unreachable
        code)
        N(   Rx  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    c         C   s0   |  j  |  |  j | d t j t j f  d S(   s   1 - check is the node has a right sibling (if so, that's some
        unreachable code)
        2 - check is the node is inside the finally clause of a try...finally
        block
        R   N(   Rx  Ry  R;   RL   RX   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR  "  s    c         C   s   |  j  |  d S(   s\   check if the node has a right sibling (if so, that's some unreachable
        code)
        N(   Rx  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_raise.  s    c         C   s   |  j  d d | d S(   s'   just print a warning on exec statementss	   exec-usedRF   N(   R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_exec5  s    c         C   s   t  | j t j  r | j j } | | j   k pB | | j   k s | d k rg |  j d d | q | d k r |  j |  q | d k r |  j d d | q q n  d S(   so   visit a Call node -> check if this is not a blacklisted builtin
        call and check for * or ** use
        t   execs	   exec-usedRF   t   reversedt   evals	   eval-usedN(	   R9   R  R;   Rz   RD   R   t   rootR   t   _check_reversed(   R   RF   RD   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR  :  s    c         C   sV   | j  d k rR t | j t j  rR t | j j  d k rR |  j d d | n  d S(   s0   check the use of an assert statement on a tuple.i   s   assert-on-tupleRF   N(	   t   failR   R9   R?  R;   R   R   t   eltsR   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_assertL  s    $c         C   sz   t    } xj | j D]_ \ } } t | t j  r | j } | | k rb |  j d d | d | n  | j |  q q Wd S(   s!   check duplicate key in dictionarys   duplicate-keyRF   R   N(   R3   t   itemsR9   R;   R   R   R   R   (   R   RF   t   keyst   kRR  t   key(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_dictS  s    		c         C   s   |  j  j |  d S(   s   update try...finally flagN(   R9  R   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_tryfinally^  s    c         C   s   |  j  j   d S(   s   update try...finally flagN(   R9  t   pop(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   leave_tryfinallyb  s    c         C   s2   | j    } | d k	 r. |  j d d | n  d S(   s   check unreachable codeR)  RF   N(   t   next_siblingR   R   (   R   RF   t   unreach_stmt(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRx  f  s    c         C   s   |  j  s d S| j } | } xd | r t | |  r t | d  rp | | j k rp |  j d d | d | d S| } | j } q Wd S(   s   check that a node is not inside a finally clause of a
        try...finally statement.
        If we found before a try...finally bloc a parent which its type is
        in breaker_classes, we skip the whole check.NR  s   lost-exceptionRF   R   (   R9  R:   R9   t   hasattrR  R   (   R   RF   R   t   breaker_classest   _parentR_   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRy  l  s    		c         C   s*  y" t  j t  j | d d  } Wn t  j k
 r8 nX| t j k rL d S| d k r t | j d t j	  r y  t
 | j d j j    } Wn t j k
 r d SXt | d d  d k r t  j |  r |  j d d | q n  d St | t j  r| j j d k r:t  j | j  r:|  j d d | d St d	   | j j   D  ry | j t Wn$ t k
 r|  j d d | n Xd Sx t D]A } x8 | D]/ } y | j |  Wqt j k
 rPqXqWPqW|  j d d | n1 t | t j t j f  s&|  j d d | n  d S(
   s5    check that the argument to `reversed` is a sequence t   positioni    NRD   t   iters   bad-reversed-sequenceRF   R4   c         s   s-   |  ]# } | j  d  k o$ t j |  Vq d S(   R4   N(   RD   R   t   is_builtin_object(   R^   R  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>  s   (   R   R}   t   get_argument_from_callt   NoSuchArgumentErrorR;   t   YESR   R9   R   R   Rq  R  R  R  RY   R  R   Rr  t   _proxiedRD   R+   R  R	  t   REVERSED_PROTOCOL_METHODR   t   REVERSED_METHODSt   NotFoundErrorR   R   (   R   RF   R   R  t   methodst   meth(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR  ~  sL    " 		c         C   s   t  sM g  } | j } t | t j  r: | j | j  n  | j | j  n	 | j } | r x t | | d  D]} \ } } t | d t j  rp | d d  k rp t | d t j
  rp t  s | j | j j k r |  j d d | q qp qp Wn  d  S(   Ni   i    s   confusing-with-statementRF   (   t   PY3KR:   R9   R;   t   Witht   extendR  R    t
   AssignNameR   R   R  R   (   R   RF   t   pairst   parent_nodet	   prev_pairt   pair(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_with  s    		 '(   s   Unreachable codeR)  sb   Used when there is some code behind a "return" or "raise" statement, which will never be accessed.(   s&   Dangerous default value %s as arguments   dangerous-default-values_   Used when a mutable value as list or dictionary is detected in a default value for an argument.(   s!   Statement seems to have no effects   pointless-statementsE   Used when a statement doesn't have (or at least seems to) any effect.(   s   String statement has no effects   pointless-string-statements   Used when a string is used as a statement (which of course has no effect). This is a particular case of W0104 with its own message so you can easily disable it if you're using those strings as documentation, instead of comments.(   s&   Expression "%s" is assigned to nothings   expression-not-assignedsq   Used when an expression that is not a function call is assigned to nothing. Probably something else was intended.(   s   Lambda may not be necessarys   unnecessary-lambdas   Used when the body of a lambda expression is a function call on the same argument list as the lambda itself; such lambda expressions are in all but a few cases replaceable with the function being called in the body of the lambda.(   s   Duplicate key %r in dictionarys   duplicate-keysD   Used when a dictionary expression binds the same key multiple times.(   s   Use of execs	   exec-useds~   Used when you use the "exec" statement (function for Python 3), to discourage its usage. That doesn't mean you cannot use it !(   s   Use of evals	   eval-useds   Used when you use the "eval" function, to discourage its usage. Consider using `ast.literal_eval` for safely evaluating strings containing Python expressions from untrusted sources. (   s3   %s statement in finally block may swallow exceptions   lost-exceptions   Used when a break or a return statement is found inside the finally clause of a try...finally block: the exceptions raised in the try clause will be silently swallowed instead of being re-raised.(   s5   Assert called on a 2-uple. Did you mean 'assert x,y'?s   assert-on-tuples   A call of assert on a tuple will always evaluate to true if the tuple is not empty, and will always evaluate to false if it is.(   s?   Following "as" with another context manager looks like a tuple.s   confusing-with-statements2  Emitted when a `with` statement component returns multiple values and uses name binding with `as` only for a part of those values, as in with ctx() as a, b. This can be misleading, since it's not clear if the context manager returns a tuple or if the node without a name binding is another context manager.(   s3   Using a conditional statement with a constant values   using-constant-tests   Emitted when a conditional statement (If or ternary if) uses a constant value for its test. This might not be what the user intended to do.(   s/   The first reversed() argument is not a sequences   bad-reversed-sequences   Used when the first argument to reversed() builtin isn't a sequence (does not implement __reversed__, nor __getitem__ and __len__(    (*   R   R   t   __doc__R   R   R   RD   R%  R   t   reportsR   R=  R   R&  R@  RA  RD  R>  RS  R   R]  t   staticmethodRa  Rc  Rm  R   R'  Rn  R   R   R  Rz  R{  R  R  R  R  R  Rx  Ry  R  R  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR(    s   		                            
					%4	&				3R	   R
   R   R   R   R   R   R   R   R   t   constantt	   attributes   class attributes   inline iterationc          C   s   g  }  x t  D] } t | } t | } | j d d  } |  j d | f i | d 6d d 6t t j    d 6d d	 6d
 | f d 6f  |  j d | f i d  d 6d d 6d d	 6d | | f d 6f  q Wt	 |   S(   NRR  t   -s   %s-naming-styleR  t   choiceR   t   choicess   <style>t   metavars&   Naming style matching correct %s namest   helps   %s-rgxt   regexps   <regexp>sG   Regular expression matching correct %s names. Overrides %s-naming-style(
   t   KNOWN_NAME_TYPESt   HUMAN_READABLE_TYPESt   DEFAULT_NAMING_STYLESt   replaceR   R5   t   NAMING_STYLESR  R   RR   (   t   name_optionsR   t   human_readable_namet   default_style(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _create_naming_options  s     



!
t   NameCheckerc        	   B   s  e  Z i dC d 6dD d 6dE d 6Z d i dF d 6d d 6d d 6d d 6f d i dG d 6d d 6d d 6d! d 6f d" i dH d 6d d 6d# d 6d$ d 6f d% i e d 6d& d 6d' d 6d( d 6f d) i dI d 6d d 6d+ d 6d, d 6f f e   Z i d- d. h dJ 6d1 d2 h dK 6Z d4   Z d5   Z d6   Z	 e
 j d d  d7    Z d8   Z e
 j d d d	  d9    Z e
 j d d d	  d:    Z e Z e
 j d d  d;    Z e
 j d d d	  d<    Z d=   Z d>   Z d?   Z e j d@  Z dA   Z e dB    Z RS(L   s   Black listed name "%s"s   blacklisted-namesD   Used when the name is listed in the black list (unauthorized names).t   C0102s"   %s name "%s" doesn't conform to %ss   invalid-namesi   Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).t   C0103s*   Name %s will become a keyword in Python %ss   assign-to-new-keywords`   Used when assignment will become invalid in future Python release due to introducing new keywordt   W0111s
   good-namest   it   jR  t   ext   RunRR  R  t   csvR   s   <names>R  sI   Good variable names which should always be accepted, separated by a commaR  s	   bad-namest   foot   bart   bazt   totot   tutut   tatasG   Bad variable names which should always be refused, separated by a commas
   name-groups   <name1:name2>sr   Colon-delimited sets of names that determine each other's naming style when the name regexes allow several styles.s   include-naming-hintt   yns   <y_or_n>s>   Include a hint for the correct naming format with invalid-names   property-classess   abc.abstractpropertys   <decorator names>s   List of decorators that produce properties, such as abc.abstractproperty. Add to this list to register other decorators that produce valid properties.RE   R?   i   i    t   asynct   awaiti   c         C   sA   t  j |  |  i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ d  S(   N(   R   R   t   _name_categoryt   _name_groupt
   _bad_namest   _name_regexpst   _name_hints(   R   R:  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   8  s    				c         C   s   |  j  j d d d d d d d d d d d d d d d	 d d
 d d d  
|  _ xB |  j j D]4 } x+ | j d  D] } d | f |  j | <qq Wq[ W|  j   \ } } | |  _ | |  _	 d  S(   Nt   badname_modulei    t   badname_classt   badname_functiont   badname_methodt   badname_attrt   badname_constt   badname_variablet   badname_inlinevart   badname_argumentt   badname_class_attributet   :s   group_%s(
   R:  R<  R   Rs   t
   name_groupt   splitR  t   _create_naming_rulesR  R  (   R   t   groupR   t   regexpst   hints(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR=  @  s    	c         C   s   i  } i  } x t  D] } d | f } t |  j |  } t | j |  | | <d | f } t |  j | d   } | d  k	 r | | | <n  | d  k	 r d | j | | <q d | | | <q W| | f S(   Ns   %s_naming_styles   %s_rgxs
   %r patterns   %s naming style(   R  RY   Rs   R  R   R   t   pattern(   R   R  R  R   t   naming_style_option_namet   naming_style_namet   custom_regex_setting_namet   custom_regex(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR  Q  s    c         C   s0   |  j  d | j j d  d |  i  |  _ d  S(   NR	   R6   i(   t   _check_nameRD   R  R  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRS  g  s    #c   	      C   s  xt  j |  j  D] } t |  d k  r1 q n  t j t  } t j } xC t  j |  D]2 } | t |  j	 |  t
 t |  |  } qY Wt | |  d k r t | | d d   } t j | d   } n | | d } x | D] } |  j |   q Wq Wd  S(   Ni   i   R  c         S   s   t  d   |  D  S(   Nc         s   s   |  ] } | d  j  Vq d S(   i    N(   R  (   R^   t   warning(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pys	   <genexpr>w  s    (   t   min(   R  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRp  w  s    i    (   RT  t
   itervaluesR  R   t   collectionst   defaultdictR5   t   syst   maxsizeR   R  t   sortedR   R   t   _raise_name_warning(	   R   RF   t
   all_groupst   groupst   min_warningsR  t   by_linet   warningsR   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   leave_modulel  s    	c         C   s   |  j  | j |  |  j d | j |  xO t j | j  D]; \ } } t | j |   s< |  j d | | d  q< q< Wd  S(   NR   R   i    (   t&   _check_assign_to_new_keyword_violationRD   R  RT  t	   iteritemst   instance_attrsR+   t   instance_attr_ancestors(   R   RF   R   t   anodes(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   ~  s
    c         C   s   |  j  | j |  t j } | j   rw t j | j j   | j  rJ d  St j	 | j j    rk t j
 n t j } n  |  j t | d |  j | j | |  | j j } | d  k	 r |  j | |  n  d  S(   NRs   (   R  RD   R   t   HIGHRx   R   t   overrides_a_methodR:   R   t   has_known_basest	   INFERENCERi   R  R   Rs   R   R   t   _recursive_check_names(   R   RF   Rl   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    	!	c         C   s+   x$ | j  D] } |  j d | |  q
 Wd  S(   NR
   (   RC   R  (   R   RF   RD   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_global  s    c         C   s  |  j  | j |  | j   } | j   } t | t j  rV |  j d | j |  net | t j  rt | t j	  r t
 |  r t t j | j  t j  r |  j d | j |  qt |  s|  j d | j |  qqt | t j  r|  j d | j |  qn t | t j  ru| j | k r| j | j   k rt |  sr|  j d | j |  qrqnF t | t j  rt | j | j   s|  j d | j |  qn  d S(   s!   check module level assigned namesR   R   R
   R   R   N(   R  RD   R   t   assign_typeR9   R;   t   ComprehensionR  RE  R   RQ   R   R}   R   Rb   RK   R<   Ra   R   R5   t   local_attr_ancestors(   R   RF   R   t   ass_type(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_assignname  s(    $c         C   sS   xL | D]D } t  | t j  r8 |  j d | j |  q |  j | j |  q Wd S(   s.   check names in a possibly recursive list <arg>R   N(   R9   R;   R  R  RD   R   R  (   R   R   RF   R`  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s    c         C   s   |  j  j | |  S(   N(   R  R   (   R   Rk   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _find_name_group  s    c         C   s   t  | } |  j | } |  j j r> | d |  j | j 7} n  | j   | | f } |  j d d | d | d | |  j d | c d 7<d  S(   Ns    (%r pattern)s   invalid-nameRF   R   Rl   R   i   (	   R  R  Rs   t   include_naming_hintR  R  t
   capitalizeR   R   (   R   RF   Rk   RD   Rl   t
   type_labelt   hintR   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s    
		c         C   s9  t  j |  r1 t  j |  \ } } | r1 d Sn  | |  j j k rG d S| |  j j k r |  j d | c d 7<|  j d d | d | d S|  j | } | j	 |  } t
 | | |  r|  j |  }	 |  j j |	 i   }
 |
 j | j g   } | j | | | | f  n  | d k r5|  j | | | |  n  d S(   s(   check for a name using the type's regexpNR   i   s   blacklisted-nameRF   R   (   R   t   is_inside_exceptt   clobber_in_exceptRs   t
   good_namest	   bad_namesR   R   R  Rj   Rm   R  R  t
   setdefaultRg   R   R   R  (   R   Rk   RD   RF   Rl   t
   clobberingRR  R  Rj   R  t   bad_name_groupR  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s&    c         C   sP   |  j  | |  j  } | d  k	 rL |  j d d | d | | f d t j n  d  S(   Ns   assign-to-new-keywordRF   R   Rl   (   t   _name_became_keyword_in_versiont   KEYWORD_ONSETR   R   R   R  (   R   RD   RF   t   keyword_first_version(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s    c         C   sR   xK | j    D]= \ } } |  | k r t j | k  r d j t t |   Sq Wd  S(   NR6   (   R  R  t   version_infot   joint   mapR   R   (   RD   t   rulest   versionRg  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s    (   s   Black listed name "%s"s   blacklisted-namesD   Used when the name is listed in the black list (unauthorized names).(   s"   %s name "%s" doesn't conform to %ss   invalid-namesi   Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).(   s*   Name %s will become a keyword in Python %ss   assign-to-new-keywords`   Used when assignment will become invalid in future Python release due to introducing new keyword(   R  R  R  R  R  RR  (   R  R  R  R  R  R  (    (   s   abc.abstractproperty(   i   i    (   i   i   (   R   R   R%  R?   R  t   optionsR  R   R=  R  R   R&  RS  R  R   R   R'  R  R  R   R  R  R   R  R  R  R  R  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    sd         









									t   DocStringCheckerc           B   s   e  Z i d d 6d d 6Z d i e d	 6d
 d 6d d 6d d 6f d i d d	 6d d 6d d 6d d 6f f Z d   Z e j d d  d    Z e j d d  d    Z	 e
 d    Z e j d d  d    Z e Z e e j d  Z RS(   s   Missing %s docstrings   missing-docstrings   Used when a module, function, class or method has no docstring.Some special methods like __init__ doesn't necessary require a docstring.t   C0111s   Empty %s docstrings   empty-docstrings^   Used when a module, function, class or method has an empty docstring (it would be too easy ;).t   C0112s   no-docstring-rgxR  R  R   s   <regexp>R  sc   Regular expression which should only match function or class names that do not require a docstring.R  s   docstring-min-lengthit   ints   <int>s[   Minimum line length for functions/classes that require docstrings, shorter ones are exempt.c      	   C   s.   |  j  j d d d d d d d d  |  _ d  S(   Nt   undocumented_modulei    t   undocumented_functiont   undocumented_methodt   undocumented_class(   R:  R<  R   (   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR=    s    c         C   s   |  j  d |  d  S(   NR	   (   t   _check_docstring(   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRS  !  s    c         C   s5   |  j  j j | j  d  k r1 |  j d |  n  d  S(   NR   (   Rs   t   no_docstring_rgxRj   RD   R   R$  (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   %  s    c         C   sL   d d h } x9 |  j  j D]+ } t | t j  r | j | k r t Sq Wt S(   NRv   Rw   (   Ry   R   R9   R;   R{   R|   RE   R?   (   RF   RC   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _is_setter_or_deleter*  s    c         C   s&  |  j  j j | j  d  k r"| j   r0 d n d } | j rR |  j |  rR d  St | j	 j
   t j  rt } t j | j	 j
    r t j n t j } xO | j	 j
   j   D]8 } | j | k r t | | j t j  r t } Pq q W|  j | | d | d | q"|  j | |  n  d  S(   NR   R   t   report_missingRl   (   Rs   R%  Rj   RD   R   Rx   Ry   R&  R9   R:   R   R;   Rb   R?   R   R  R   R  Ri   R  Ra   RE   R$  (   R   RF   t   ftypet
   overriddenRl   R  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR   3  s"    !	
c   	      C   s  | j  } | d k rr| s d St |  | j } | d k rI | rI d S|  j j } | d k r} | d k r} | | k  r} d S|  j d | c d 7<| j rMt | j d t	 j
  rMt | j d j t	 j  rMt j | j d j j  } t | t	 j  rMt | j t	 j  rMt r1| j j d k r1d S| j j d k rJd SqMn  |  j d
 d | d | f d | nH | j   s|  j d | c d 7<|  j d d | d | f d | n  d S(   s(   check the node has a non empty docstringNR	   iR   i   i    R   t   unicodet   bytess   missing-docstringRF   R   Rl   s   empty-docstring(   R   R*  R+  (   t   docR   R   R  Rs   t   docstring_min_lengthR   RZ  R9   R;   t   ExprR   R   R   R}   R  RJ  t   boundRr  R  RD   R   t   strip(	   R   Rk   RF   R'  Rl   t	   docstringR   t	   max_linesR  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR$  L  s4    	$"

(   s   Missing %s docstrings   missing-docstrings   Used when a module, function, class or method has no docstring.Some special methods like __init__ doesn't necessary require a docstring.(   s   Empty %s docstrings   empty-docstrings^   Used when a module, function, class or method has an empty docstring (it would be too easy ;).(   R   R   R%  t   NO_REQUIRED_DOC_RGXR  R=  R   R&  RS  R   R  R&  R   R'  RE   R   R  R$  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR     s.       



		t   PassCheckerc           B   s3   e  Z d  Z i d d 6Z e j d  d    Z RS(   s/   check if the pass statement is really necessarys   Unnecessary pass statements   unnecessary-passs@   Used when a "pass" statement that can be avoided is encountered.t   W0107c         C   s8   t  | j j |   d k r4 |  j d d | n  d  S(   Ni   s   unnecessary-passRF   (   R   R:   t   child_sequenceR   (   R   RF   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt
   visit_passy  s    (   s   Unnecessary pass statements   unnecessary-passs@   Used when a "pass" statement that can be avoided is encountered.(   R   R   R  R%  R   R&  R7  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR4  q  s
    
t   LambdaForComprehensionCheckerc           B   sF   e  Z d  Z i d d d i d	 d 6f d 6Z e j d  d    Z RS(
   s   check for using a lambda where a comprehension would do.

    See <http://www.artima.com/weblogs/viewpost.jsp?thread=98196>
    where GvR says comprehensions would be clearer.
    s7   map/filter on lambda could be replaced by comprehensions   deprecated-lambdas   Used when a lambda is the first argument to "map" or "filter". It could be clearer as a list comprehension or generator expression.i   i    R   t   W0110c         C   st   | j  s d St | j  d t j  s* d St j | j  } t j |  rp | j d k rp |  j	 d d | n  d S(   sS   visit a Call node, check if map or filter are called with a
        lambda
        Ni    R  t   filters   deprecated-lambdaRF   (   R  R:  (
   R   R9   R;   R  R   R}   R  R  RD   R   (   R   RF   R   (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR    s    	(   i   i    (   R   R   R  R%  R   R&  R  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR8    s   c         C   s/   t  |  t j  o. t |  j  d k o. |  j S(   sS   Is this a call with exactly 1 argument,
    where that argument is positional?
    i   (   R9   R;   R   R   R   Rg  (   Ri  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _is_one_arg_pos_call  s    t   ComparisonCheckerc           B   s   e  Z d  Z i d d 6d d 6d	 d
 d i d g d 6f d 6d d 6Z d   Z d   Z d   Z e j d d d
 d  d    Z	 d   Z
 d   Z RS(   s  Checks for comparisons

    - singleton comparison: 'expr == True', 'expr == False' and 'expr == None'
    - yoda condition: 'const "comp" right' where comp can be '==', '!=', '<',
      '<=', '>' or '>=', and right can be a variable, an attribute, a method or
      a function
    s   Comparison to %s should be %ss   singleton-comparisonsQ   Used when an expression is compared to singleton values like True, False or None.t   C0121s   Comparison should be %ss   misplaced-comparison-constants   Used when the constant is placed on the left side of a comparison. It is usually clearer in intent to place it in the right hand side of the comparison.t   C0122s5   Using type() instead of isinstance() for a typecheck.s   unidiomatic-typechecks   The idiomatic way to perform an explicit typecheck in Python is to use isinstance(x, Y) rather than type(x) == Y, type(x) is Y. Though there are unusual situations where these give different results.t   W0154t	   old_namest   C0123s   Comparison to literals   literal-comparisons   Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.t   R0123c         C   s   | j  t k r7 d } |  j d d | d t | f nb | j  t k rn d } |  j d d | d t | f n+ | j  d  k r |  j d d | d d n  d  S(   Ns   just 'expr' or 'expr is True's   singleton-comparisonRF   R   s   'not expr' or 'expr is False's   'expr is None'(   Ns   'expr is None'(   R   RE   R   R?   R   (   R   t	   singletont	   root_nodet
   suggestion(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _check_singleton_comparison  s    c         C   s   t  j t  j t  j t  j f } t | |  } t } t | t  j  r | j t	 t d f k ra d St | j t t t t f  } n  | s | r |  j d d | n  d S(   sM   Check if we compare to a literal, which is usually what we do not want to do.Ns   literal-comparisonRF   (   R;   R   R   R   R   R9   R?   R   R   RE   R   R+  R   R  t   floatR   (   R   t   literalRF   R   t   is_other_literalt   is_const(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _check_literal_comparison  s    !c         C   sd   t  | t j  r d  St j | |  } d | j   | | j f } |  j d d | d | f d  S(   Ns   %s %s %rs   misplaced-comparison-constantRF   R   (   R9   R;   R   t   REVERSED_COMPSR   R[  R   R   (   R   RF   t   leftt   rightt   operatorRE  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   _check_misplaced_constant  s    c         C   s   |  j  |  t | j  d k r& d  S| j } | j d \ } } | d k ry t | t j  ry |  j | | | |  n  | d k r t | t j  r |  j | |  q t | t j  r |  j | |  q n  | d k r |  j	 | |  n  d  S(   Ni   i    R8   s   <=R7   s   >=s   !=s   ==R/   s   is not(   R8   s   <=R7   s   >=s   !=s   ==(   R/   s   is not(
   t   _check_unidiomatic_typecheckR   t   opsRM  R9   R;   R   RP  RF  RK  (   R   RF   RM  RO  RN  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   visit_compare  s    	c         C   sT   | j  d \ } } | t k rP | j } t |  rP |  j | | | |  qP n  d  S(   Ni    (   RR  t   TYPECHECK_COMPARISON_OPERATORSRM  R;  t   _check_type_x_is_y(   R   RF   RO  RN  RM  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRQ    s
    	c         C   s   t  j | j  } t | t j  o3 | j   t k s: d S| d k r t |  r t  j | j  } t | t j  r | j   t k r t  j | j	 d  } t | t
  s d Sq n  |  j d d | d S(   s(   Check for expressions like type(x) == Y.NR/   s   is noti    s   unidiomatic-typecheckRF   (   R/   s   is not(   R   R}   R  R9   R;   Rb   R~   t
   TYPE_QNAMER;  R   t   LITERAL_NODE_TYPESR   (   R   RF   RM  RO  RN  t	   left_funct
   right_funct	   right_arg(    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyRU    s    
(   s   Comparison to %s should be %ss   singleton-comparisonsQ   Used when an expression is compared to singleton values like True, False or None.(   s   Comparison should be %ss   misplaced-comparison-constants   Used when the constant is placed on the left side of a comparison. It is usually clearer in intent to place it in the right hand side of the comparison.(   R?  s   unidiomatic-typecheck(   s   Comparison to literals   literal-comparisons   Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.(   R   R   R  R%  RF  RK  RP  R   R&  RS  RQ  RU  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyR<    s*        
				c         C   s   |  j  t |    |  j  t |    |  j  t |    |  j  t |    |  j  t |    |  j  t |    |  j  t |    d S(   s-   required method to auto register this checkerN(   t   register_checkerR   R(  R  R  R4  R8  R<  (   R:  (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   register  s    (Y   R  R  R   R  R!   RT  t	   six.movesR    R;   t   astroid.basest   astroid.scoped_nodest   pylintR   R   R   t   pylint.checkersR   R   t   pylint.checkers.utilsR   t   pylint.reporters.ureportsR   R   t   pylint.utilsR   t   objectR   R    R#   R$   R%   R&   R  R"   R3  R  t   SEQUENCE_PROTOCOL_METHODSR  t	   frozensetRT  R   R   R   R   RW  t   UNITTEST_CASEt   movest   builtinsR   t   BUILTINSRV  R  R   R  R   Rh   R4   t   xR  Rs  RL  RK   RQ   RS   R\   Rf   Rm   Rp   Ru   R   R   R   R   R   t   BaseCheckerR   R   R(  R  R  R  R  R  R  R4  R8  R;  R<  R\  (    (    (    s3   lib/python2.7/site-packages/pylint/checkers/base.pyt   <module>   s   				

1"								#	
	)	 Y 

	q	y