
    e                       d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlZddlmZmZmZ ddlmZ ddlmZmZ dd	lmZmZmZ dd
lmZ ddlmZ erddlmZ  G d de      ZdZdZ e effZ! e" e#dD  cg c]  } djI                  d| g       c} g d      fi dD  ci c]  } | |  d
 c} Z%	 	 	 	 	 	 	 	 ddZ& G d de      Z'yc c} w c c} w )zBasic checker for Python code.    )annotationsN)Iterator)TYPE_CHECKINGLiteralcast)nodesobjectsutil)utils)BaseCheckerr   )HIGH	INFERENCE
Confidence)r   )LinterStats)PyLinterc                      e Zd ZdZdZy)_BasicCheckerzYPermits separating multiple checks with the same checker name into
    classes/file.
    basicN)__name__
__module____qualname____doc__name     D/usr/lib/python3/dist-packages/pylint/checkers/base/basic_checker.pyr   r      s     Dr   r   __reversed__)__getitem____len__)setdictlist.builtins)zset()z{}z[])zcollections.dequezcollections.ChainMapzcollections.Counterzcollections.OrderedDictzcollections.defaultdictzcollections.UserDictzcollections.UserListz()c                   i }dD ]|  }t        t        d   |      }|j                  |      }i ||<   |dk7  s2|j                  |      }||z
  }|dz  |z  }|d||   d<   |j	                  |      }	|	dz  |z  }|d||   d<   ~ g d}
dD ]  }t        t        d   |      }|j                  |      }|r|j                  |      nd	}|rt        j                  ||      nd	}|
|t        |      |rt        |      nd
|r|nd
||   j                  dd      ||   j                  dd      gz  }
 | j                  t        j                  |
dd             y	)zzMake a report of.

    * percentage of different types documented
    * percentage of different types with a bad name
    )moduleclassmethodfunction)r)   r'   r(   r&   r   g      Y@z.2fpercent_documentedpercent_badname)typenumberz
old number
differencez%documentedz%badnameNNC0      )childrencolsrheaders)r   r   get_node_countget_undocumentedget_bad_names
lint_utilsdiff_stringstrgetappendreporter_nodesTable)sectstats	old_stats
nice_stats	node_typetotalundocumented_node
documentedpercentbadname_nodelinesnewolddiff_strs                 r   report_by_type_statsrN   <   s    -/J> H	!HI9U	$$Y/ "
9A: % 6 6y A!22J!E)U2G=DSMJy!"67 ..y9L#e+u4G:A#Jy!"34H VE> 
	!HI9U	""9-5>i&&y1D7::))#s3HCH Hdy!%%&:C@y!%%&7=
 	

 	KK$$e!aHIr   c                      e Zd ZdZdZi ddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+Zd,d-effZdf fd.Zdgd/Z	 e
j                  d0d1      dhd2       Z e
j                  d0d1      did3       Z e
j                  d0d1      djd4       Z	 	 	 	 	 	 dkd5Zedld6       Zdmd7Zdnd8Z e
j                  d9d:d;d<d=      dod>       Ze	 	 	 	 	 	 dpd?       Ze	 	 	 	 	 	 dqd@       Z e
j                  dA      drdB       Z e
j                  dC      dsdD       ZeZdsdEZ e
j                  dFdG      dtdH       Z e
j                  dF      dudI       Z e
j                  dFdG      dvdJ       Z e
j                  dF      dwdK       ZdxdLZ e
j                  dMdNdOdPdF      dydQ       Z  e
j                  dRdS      dzdT       Z! e
j                  dU      d{dV       Z" e
j                  dW      d|dX       Z#d}dYZ$d~dZZ%e&f	 	 	 	 	 dd[Z'	 d	 	 	 	 	 	 	 dd\Z(dyd]Z) e
j                  d^      dd_       Z*dd`Z+ddaZ, e
j                  dbdc      ddd       Z- e
j                  dc      dde       Z. xZ/S )BasicCheckera>  Basic checker.

    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   W0101)zUnreachable codeunreachablezbUsed when there is some code behind a "return" or "raise" statement, which will never be accessed.W0102)z&Dangerous default value %s as argumentdangerous-default-valuez_Used when a mutable value as list or dictionary is detected in a default value for an argument.W0104)z!Statement seems to have no effectpointless-statementzEUsed when a statement doesn't have (or at least seems to) any effect.W0105)zString statement has no effectpointless-string-statementzUsed 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.W0106)z&Expression "%s" is assigned to nothingexpression-not-assignedzqUsed when an expression that is not a function call is assigned to nothing. Probably something else was intended.W0108)zLambda may not be necessaryunnecessary-lambdazUsed 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.W0109)zDuplicate key %r in dictionaryduplicate-keyzDUsed when a dictionary expression binds the same key multiple times.W0122)zUse of exec	exec-useda  Raised when the 'exec' statement is used. It's dangerous to use this function for a user input, and it's also slower than actual code in general. This doesn't mean you should never use it, but you should consider alternatives first and restrict the functions available.W0123)zUse of eval	eval-usedzUsed 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.W0150)z3%s statement in finally block may swallow exceptionlost-exceptionzUsed 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.W0199)z>Assert called on a populated tuple. Did you mean 'assert x,y'?assert-on-tuplez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.W0124)z?Following "as" with another context manager looks like a tuple.confusing-with-statementa2  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.W0125)z3Using a conditional statement with a constant valueusing-constant-testzEmitted 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.W0126)zgUsing a conditional statement with potentially wrong function or method call due to missing parentheses$missing-parentheses-for-call-in-testzsEmitted when a conditional statement (If or ternary if) seems to wrongly call a function due to missing parenthesesW0127)z(Assigning the same variable %r to itselfself-assigning-variablez<Emitted when we detect that a variable is assigned to itselfW0128)z$Redeclared variable %r in assignmentredeclared-assigned-namezMEmitted when we detect that a variable was redeclared in the same assignment.E0111)z/The first reversed() argument is not a sequencebad-reversed-sequencezUsed when the first argument to reversed() builtin isn't a sequence (does not implement __reversed__, nor __getitem__ and __len__)z$format function is not called on strmisplaced-format-functionzEmitted when format function is not called on str object. e.g doing print("value: {}").format(123) instead of print("value: {}".format(123)). This might not be what the user intended to do.)zUAssert statement has a string literal as its first argument. The assert will %s fail.assert-on-string-literalzuUsed when an assert statement has a string literal as its first argument, which will cause the assert to always pass.)zDuplicate value %r in setduplicate-valuezMThis message is emitted when a set contains the same value two or more times.)z%Named expression used without contextnamed-expr-without-contextzyEmitted if named expression is used to do a regular assignment outside a context like if, for, while, or a comprehension.)z!Exception statement has no effectpointless-exception-statementzjUsed when an exception is created without being assigned, raised or returned for subsequent use elsewhere.)z*'return' shadowed by the 'finally' clause.return-in-finallyzEmitted when a 'return' statement is found in a 'finally' block. This will overwrite the return value of a function and should be avoided.)E0119W0129W0130W0131W0133W0134RP0101zStatistics by typec                (    t         |   |       |  y N)super__init__)selflinter	__class__s     r   r   zBasicChecker.__init__  s     r   c                    | j                   j                  j                  }|dk\  | _        g | _        | j                   j
                  j                          y)z*Initialize visit variables and statistics.)      N)r   config
py_version
_py38_plus_trysrA   reset_node_count)r   r   s     r   openzBasicChecker.open  s@    [[''22
$.
**,r   rj   rl   c                <    | j                  ||j                         y r   _check_using_constant_testtestr   nodes     r   visit_ifzBasicChecker.visit_if       	''dii8r   c                <    | j                  ||j                         y r   r   r   s     r   visit_ifexpzBasicChecker.visit_ifexp"  r   r   c                d    |j                   r$|j                   D ]  }| j                  ||        y y r   )ifsr   )r   r   if_tests      r   visit_comprehensionz BasicChecker.visit_comprehension(  s3     8888 ?//g>? r   c           	        t         j                  t         j                  t         j                  t         j                  t         j
                  t        j                  j                  t        j                  t        j                  t         j                  f	}t         j                  t         j                  t         j                  t         j                  f}t         j                  t         j                   t         j"                  t         j$                  t         j&                  f}d }t)        |t         j*                  g||      }d }t)        ||      sbt-        j.                  |      }t)        |t0        j2                        rOt)        |t         j4                        r5t6        j9                  |      \  }}nt)        |t         j                        r|}|rt-        j.                  |j:                        }	t)        |	t         j                        r\d }
|	j=                         D ],  }t)        |j>                  t         j                        sd}
 nd}
. |
r| jA                  d|tB               y |r| jA                  d|tB               y t)        ||      rd }	 t)        |t         j                        rtE        |jG                  |            }n4t)        |t         j                        rtE        |jG                  |            }|r| jA                  d|tB               | jA                  d|tB               y y # t        jH                  $ r d }Y Kw xY w)NFTrj   r   
confidencerl   )%r   ModuleGeneratorExpLambdaFunctionDefClassDefastroidbases	GeneratorUnboundMethodBoundMethodDictTupleSetListCallBinOpBoolOpUnaryOp	Subscript
isinstanceConstr   
safe_inferr
   UninferableBaseNamerP   _name_holds_generatorfunc _get_return_nodes_skip_functionsvalueadd_messager   r"   infer_call_resultInferenceError)r   r   r   const_nodesstructsexcept_nodesinferredemitmaybe_generator_callinferred_callall_returns_were_generatorreturn_nodecall_inferreds                r   r   z'BasicChecker._check_using_constant_test0  s    LLLLNNMM##!!LL

 ::u{{EIIuzzB
 JJKKLLMMOO
 $ Ew E EF#$-''-H(D$8$89jejj? .:-O-OPT-U** ejj)#' !,,-A-F-FGM-):):; .2*#0#Q#Q#S 6K%k&7&79K9KL5:215.	6
 .$$-DY %  2)T+. !M	% h(9(9:$()C)CD)I$JM%,,7$()C)CD)I$JM   :( ! 
 2)T) / )) % $%s   A)L+ +MMc                >   t        | t        j                        sJ d}d}| j                         j	                  | j
                        }|s||fS d |d   D        }t        |d      }|t        t        j                  |f|            rd}||fS t        |d         dk(  rzt        |d   d   j                  t        j                        rPt        |d   d   j                  j                  t        j                        r|d   d   j                  j                  }||fS )zReturn whether `test` tests a name certain to hold a generator, or optionally
        a call that should be then tested to see if *it* returns only generators.
        FNc              3     K   | ]V  }t        |j                  t        j                        r0t        |j                  j                  t        j
                         X y wr   )r   parentr   Assignr   r   ).0assign_names     r   	<genexpr>z5BasicChecker._name_holds_generator.<locals>.<genexpr>  sE      $
+,,ell; {))//1C1CD$
s   AAr2   Tr   )r   r   r   framelookupr   nextall	itertoolschainlenr   r   r   r   )r   r   r   lookup_resultmaybe_generator_assigned
first_items         r   r   z"BasicChecker._name_holds_generator  s   
 $

+++#

++DII6---$
,Q/$
 
 2D9
!9??J=2JKL ))) M!$%*}Q/2995<<H}Q/299??L'4Q'7':'A'A'G'G$)))r   c                Z    | j                   j                  j                  dxx   dz  cc<   y)z4Check module name, docstring and required arguments.r&   r2   Nr   rA   
node_countr   _s     r   visit_modulezBasicChecker.visit_module  s"    $$X.!3.r   c                Z    | j                   j                  j                  dxx   dz  cc<   y)zXCheck module name, docstring and redefinition
        increment branch counter.
        klassr2   Nr   r   s     r   visit_classdefzBasicChecker.visit_classdef  s$     	$$W-2-r   rV   rw   rX   rZ   rv   c                v   |j                   }t        |t        j                        rt        |j                   t              r|j                         }t        |t        j                  t        j                  t        j                  f      rt        |t        j                        r|j                  dk7  rn^|j                         }|L|j                         |u r:t        |t        j                  t        j                  t        j                  f      ry| j                  d|       yt        |t        j                        rd}t        |j                   t        j"                        r|j                   j                  }n:t        |j                   t        j$                        r|j                   j&                  }|dd j)                         rt+        j,                  |      nd}t        |t.        j0                        r| j                  d|t2               yt        |t        j4                  t        j6                  f      sjt        |j8                  t        j:                        r|j8                  j<                  |gk(  s,t        |t        j                        r|j                   t>        u ryt        |t        j@                        r| j                  d	|tB               ytE        |jG                  t        j                              r#| j                  d
||jI                                y| j                  d|       y)z4Check for various kind of statements without effect.r   NrX   r    r2   rw   r   rv   rZ   r   argsrV   )%r   r   r   r   r;   scoper   r   r   r   previous_siblingr   	AnnAssign	TypeAliasr   r   r   r   	Attributeattrnameisupperr   r   r	   ExceptionInstancer   YieldAwaitr   TrybodyEllipsis	NamedExprr   anynodes_of_class	as_string)r   r   exprr   siblingr   r   s          r   
visit_exprzBasicChecker.visit_expr  sF    zzdEKK(Z

C-H
 JJLE%%..%,,@Q@Q!RSeU%6%67EJJ*<T"335G+#MMOu4&#ellEOOU__%U 9E dEJJ'D$))UZZ0yy~~DIIu7yy))
 26bq1A1A1Cu''-H(G$=$=>  3$9 !   tekk5;;784;;		2t{{7G7GD67Q4-$**2HdEOO,9QUV$$UZZ01)4>>;K   2>r   c              #    K   |D ]x  }t        |t        j                        rXt        |j                  t        j                        sB|j                  j
                  | j                  j                  k7  sp| u| z y wr   )r   r   Starredr   r   r   r   vararg)r   	call_argsargs      r   _filter_varargzBasicChecker._filter_vararg  s[       	C#u}}-syy%**5		$))*:*::I		s   AB-B5Bc                6    |  xs t        fd| D              S )Nc              3     K   | ]j  }t        |j                  t        j                        xr |j                  j                  k7  xs% t        |j                  t        j                          l y wr   )r   r   r   r   r   )r   avariadic_names     r   r   z6BasicChecker._has_variadic_argument.<locals>.<genexpr>  s^      
  qww

+ .-3agguzz223
s   A0A3)r   )r   r  s    `r   _has_variadic_argumentz#BasicChecker._has_variadic_argument   s*     x 
3 
 	
 
 	
r   r\   c                   |j                   j                  ry|j                  }t        |t        j
                        syt        |j                  j                  t        j                        r9t        |j                  j                  j                  t        j
                        ryt        |j                   j                         }t        | j                  ||j                               }|j                   j                  r1| j                  |j                  |j                   j                        ry|j                  ry|j                   j                  r1| j                  |j                  |j                   j                        ry|j                  ryt!        |      t!        |      k7  ryt#        ||      D ]<  \  }}t        |t        j$                        s y|j&                  |j&                  k7  s< y |j                  j)                  t        j$                        D ]$  }|j+                  |j&                        d   |u s$ y | j-                  d|j.                  |       y)z'Check whether the lambda is suspicious.Nr   r\   )liner   )r   defaultsr   r   r   r   r   r   r   r"   r  kwargr  keywordsr   starargsr   zipr   r   r   r   r   
fromlineno)r   r   callordinary_argsnew_call_argsr  
passed_argr   s           r   visit_lambdazBasicChecker.visit_lambda  s    99 yy$

+ diinneoo6:IINN<

 TYY^^,T00tyyAB99??**4==$))//J]]99**4==$)):J:JK]] }]!33"=-@ 	OCj%**5xx:??*		 II,,UZZ8 	D{{499%a(D0	 	-DOO$Or   rT   c                    |j                         r,| j                  j                  j                  dxx   dz  cc<   n+| j                  j                  j                  dxx   dz  cc<   | j	                  |       y)zeCheck function name, docstring, arguments, redefinition,
        variable names, max locals.
        r(   r2   r)   N)	is_methodr   rA   r   _check_dangerous_defaultr   s     r   visit_functiondefzBasicChecker.visit_functiondefE  s\    
 >>KK((2a72KK((494%%d+r   c                H   dd}|j                   j                  xs g |j                   j                  xs g z   }|D ]I  }|s	 t        |j	                               }t        |t
        j                        s<|j                         t        v sS||u rt        |j                            }nt        |t
        j                        s ||      ry ||      r|j                         }nt        |t        j                        r!|j                   d|j                          d}nP|j                          d|j                          d}n+|j                          dt        |j                             d}| j!                  d||f       L y# t
        j                  $ r Y dw xY w)	z0Check for dangerous default values as arguments.c                t    t        | t        j                  t        j                  t        j                  f      S r   )r   r   r   r   r   )internal_nodes    r   is_iterablez:BasicChecker._check_dangerous_default.<locals>.is_iterableU  s"    mejj%))UZZ-PQQr   z() ()z (rT   r   N)r  znodes.NodeNGreturnbool)r   r
  kw_defaultsr   inferr   r   r   InstanceqnameDEFAULT_ARGUMENT_SYMBOLSpytyper   r   r   r   r   )r   r   r  r
  defaultr   msgs          r   r  z%BasicChecker._check_dangerous_defaultR  sm   	R II&&,"1F1F1L"M 	TGW]]_-
 5'"2"23KKM%==G#25;;=ACw'7'78K<N #7+#lln#GUZZ8!&DqA!(!2!2!4 5RaH %..014LU[[]4[3\\]^C  !:SF S?	T
 )) s   F

F! F!rR   rd   c                j    | j                  |       | j                  |dt        j                  f       y)zReturn node visitor.

        1 - check if the node has a right sibling (if so, that's some
        unreachable code)
        2 - check if the node is inside the 'finally' clause of a 'try...finally'
        block
        r  N)_check_unreachable_check_not_in_finallyr   r   r   s     r   visit_returnzBasicChecker.visit_returnz  s-     	%""4E4E4E3GHr   c                &    | j                  |       y)z]Check is the node has a right sibling (if so, that's some unreachable
        code).
        Nr)  r   s     r   visit_continuezBasicChecker.visit_continue      
 	%r   c                    | j                  |       | j                  |dt        j                  t        j                  f       y)zBreak node visitor.

        1 - check if the node has a right sibling (if so, that's some
        unreachable code)
        2 - check if the node is inside the 'finally' clause of a 'try...finally'
        block
        breakN)r)  r*  r   ForWhiler   s     r   visit_breakzBasicChecker.visit_break  s1     	%""4599ekk2JKr   c                &    | j                  |       y)z]Check if the node has a right sibling (if so, that's some unreachable
        code).
        Nr-  r   s     r   visit_raisezBasicChecker.visit_raise  r/  r   c                   t        |j                  t        j                        sy |j                  j                  dk7  ry t        j                  |j                  j                        }t        |t        j                        ry |s|j                  j                  }t        |t        j                        sy t        |j                  t        j                        r.|j                  j                  dk(  r| j                  d|       y y y y )Nformatprintrs   r   )r   r   r   r   r   r   r   r   r
   r   r   r   r   r   )r   	call_noder   	call_exprs       r    _check_misplaced_format_functionz-BasicChecker._check_misplaced_format_function  s    )..%//:>>""h.	 3 34dD001 "++Ii49>>5::6NN''72  !<9 M 3 7 r   rb   r`   rr   rs   c                   t        j                  |      r| j                  |t               | j	                  |       t        |j                  t        j                        r|j                  j                  }||j                         v s]||j                         v sJ|dk(  r| j                  d|       y|dk(  r| j                  |       y|dk(  r| j                  d|       yyyyy)	zVisit a Call node.)r   execr`   r   reversedevalrb   N)r   is_terminating_funcr)  r   r<  r   r   r   r   r   r   rootr   _check_reversed)r   r   r   s      r   
visit_callzBasicChecker.visit_call  s     $$T*##DY#?--d3dii,99>>D DJJL(DDIIK,?6>$$[t$<Z'((.V^$$[t$< $ -@(	 -r   rf   rt   c                   t        |j                  t        j                        r:t	        |j                  j
                        dkD  r| j                  d|t               t        |j                  t        j                        rVt        |j                  j                  t              r1|j                  j                  rd}nd}| j                  d||f       yyy)	z:Check whether assert is used on a tuple or string literal.r   rf   r   neveralwaysrt   r   N)r   r   r   r   r   eltsr   r   r   r   r;   )r   r   whens      r   visit_assertzBasicChecker.visit_assert  s     dii-#diinn2E2I.TdKdii-*TYY__c2Ryy7d$Q 3S-r   r^   c                8   t               }|j                  D ]  \  }}t        |t        j                        r|j
                  }n,t        |t        j                        r|j                         }nY||v r| j                  d||       |j                  |        y)z"Check duplicate key in dictionary.r^   r   N)
r    itemsr   r   r   r   r   r   r   add)r   r   keyskr   keys         r   
visit_dictzBasicChecker.visit_dict  s|     uJJ 		DAq!U[[)ggAu/kkmd{  t# FHHSM		r   ru   c                    t               }|j                  D ]X  }t        |t        j                        r|j
                  }n+||v r| j                  d||t               |j                  |       Z y)zCheck duplicate value in set.ru   )r   r   r   N)	r    rH  r   r   r   r   r   r   rM  )r   r   valuesvr   s        r   	visit_setzBasicChecker.visit_set  si      		A!U[[)  %Du !  JJu		r   c                    | j                   j                  |       |j                  D ]>  }|j                  t        j
                        D ]  }| j                  d|t                @ y)Update try block flag.rx   r   N)r   r=   	finalbodyr   r   Returnr   r   )r   r   
final_noder   s       r   	visit_tryzBasicChecker.visit_try  s`    

$.. 	YJ)88F Y  !4;SW XY	Yr   c                8    | j                   j                          y)rW  N)r   popr   s     r   	leave_tryzBasicChecker.leave_try  s    

r   c                (   |j                         }|t        |t        j                        rQt        |t        j                        r7t        |j
                  t        j                        r|j                         }|y| j                  d||       yy)zCheck unreachable code.NrR   r   )next_siblingr   r   rY  Exprr   r   r   )r   r   r   unreachable_statements       r   r)  zBasicChecker._check_unreachable  s     !% 1 1 3 ,4.4ejjA4::EKKH )>(J(J(L%(0$9j   -r   c                    | j                   sy|j                  }|}|r[t        ||      sNt        |d      r#||j                  v r| j                  d||       y|}|j                  }|rt        ||      sLyyyy)zCheck that a node is not inside a 'finally' clause of a
        'try...finally' statement.

        If we find a parent which type is in breaker_classes before
        a 'try...finally' block we skip the whole check.
        NrX  rd   r   )r   r   r   hasattrrX  r   )r   r   	node_namebreaker_classes_parent_nodes         r   r*  z"BasicChecker._check_not_in_finally  s{     zz++j/Bw,':K:K1K  !19 MEllG j/BgBgr   c                   	 t        j                  t        j                  |d            }t        |t        j
                        ry|t        |j                  d   t        j                        ri	 t        |j                  d   j                  j                               }t        |dd      dk(  r(t        j                  |      r| j!                  d|       yt        |t        j"                  t        j$                  f      ry| j&                  sxt        |t        j(                        r^t+        d t-        j.                  |j0                  f|j0                  j3                               D              r	 |j4                  t6            yt;        |d	      r9t<        D ]  }|D ]  }	 |j                  |         y | j!                  d|       y| j!                  d|       y# t        j                  $ r Y yw xY w# t8        $ r | j!                  d|       Y yw xY w# t        j>                  $ r Y  w xY w# t         j@                  $ r Y yw xY w)
z4Check that the argument to `reversed` is a sequence.r   )positionNr   iterrr   r   c              3  h   K   | ]*  }|j                   d k(  xr t        j                  |       , yw)r!   N)r   r   is_builtin_object)r   ancestors     r   r   z/BasicChecker._check_reversed.<locals>.<genexpr>T  s4        MMV+Q0G0G0QQs   02getattr)!r   r   get_argument_from_callr   r
   r   r   r   r   r   r   r!  r   r   ro  rm  r   r   r   r   r"  r   r   r   _proxied	ancestorslocalsREVERSED_PROTOCOL_METHODKeyErrorrd  REVERSED_METHODSNotFoundErrorNoSuchArgumentError)r   r   argumentr   methodsmeths         r   rC  zBasicChecker._check_reversed6  s%   5	E''(D(DTTU(VWH (D$8$89 diilEJJ7#DIIaL$5$5$;$;$=> fd $)$;$;D$A(()@t(L(UZZ$=>
 ??z(G<L<L'M $-OO!**,h.?.?.I.I.K% M (@A x+/ 	IG ' "$,,T2 	I $$%<4$H  !8t DQ #11 . $ M(()@t(LM  '44 "!"Y (( 		sG   *H7 10G" 5G; $H"G87G8;HHH43H47IIrh   c                    |j                   }|rmt        ||dd        D ]Z  \  }}t        |d   t        j                        s$|d   *t        |d   t        j
                        rH| j                  d|       \ y y )Nr2   r   rh   r   )rL  r  r   r   
AssignNamer   r   )r   r   pairs	prev_pairpairs        r   
visit_withzBasicChecker.visit_witho  s{     

#&ueABi#8 L	4ilE,<,<=GOJtAw

,K $$%?d$KL r   c                   |j                         }|j                  }g }|j                  }t        |d   t        j
                        r-t        |      dk7  ry |d   j                  }t        |      dk(  ry t        |j                  t        j                        rt        |      dk7  ry |j                  g}nmt        |j                  t        j
                        rIt        |j                  j                        }t        |      |k7  s|dk(  ry |j                  j                  }t        ||      D ]  \  }}t        |t        j                        s!t        |t        j                        s<t        |t        j                        r|j                  |v re|j                  |j                  k(  s| j                  d|j                  f|        y )Nr   r2   rn   r   r   )r   rs  targetsr   r   r   r   rH  r   r   r  r}  r   r   r   )	r   r   r   scope_locals	rhs_namesr  	rhs_counttargetlhs_names	            r   _check_self_assigning_variablez+BasicChecker._check_self_assigning_variable  sb    

||	,,gaj%++.7|q ajooG7|q djj%**-7|q I

EKK0DJJOO,I7|y(IN

I #GY 7 	FHh

3fe&6&67 %0V[[L5P{{hmm+  -V[[N ! 	r   c                h   | j                   j                  j                  }|D ]  }t        |t        j
                        sg }|j                  D ]  }t        |t        j
                        r| j                  |g       0t        |t        j                        sK|j                  dk7  s[|r|j                  |j                        r  y |j                  |j                          t        j                  |      }|j                         D ]   \  }}|dkD  s| j                  d|f|       "  y )Nr   r2   rp   r  )r   r   dummy_variables_rgxr   r   r   rH  _check_redeclared_assign_namer}  r   matchr=   collectionsCountermost_commonr   )	r   r  r  r  found_nameselementnamesr   counts	            r   r  z*BasicChecker._check_redeclared_assign_name  s   "kk00DD 	Ffekk2K!;; 5gu{{366yA)9)9:w||s?R*/B/H/H/V&&w||45  ''4E$002 e19$$2$v % 	r   rn   rp   c                \    | j                  |       | j                  |j                         y r   )r  r  r  r   s     r   visit_assignzBasicChecker.visit_assign  s$     	++D1**4<<8r   c                <    | j                  |j                  g       y r   )r  r  r   s     r   	visit_forzBasicChecker.visit_for  s    **DKK=9r   )r   r   r  None)r  r  )r   znodes.Ifr  r  )r   znodes.IfExpr  r  )r   znodes.Comprehensionr  r  )r   z,nodes.If | nodes.IfExp | nodes.Comprehensionr   znodes.NodeNG | Noner  r  )r   z
nodes.Namer  ztuple[bool, nodes.Call | None])r   znodes.Moduler  r  )r   znodes.ClassDefr  r  )r   z
nodes.Exprr  r  )r   nodes.Lambdar   zlist[nodes.NodeNG]r  zIterator[nodes.NodeNG])r   z#list[nodes.Starred | nodes.Keyword]r  r;   r  r  )r   r  r  r  )r   znodes.FunctionDefr  r  )r   znodes.Returnr  r  )r   znodes.Continuer  r  )r   znodes.Breakr  r  )r   znodes.Raiser  r  )r:  
nodes.Callr  r  )r   r  r  r  )r   znodes.Assertr  r  )r   z
nodes.Dictr  r  )r   z	nodes.Setr  r  )r   	nodes.Tryr  r  )r   r  r  r  )r   zFnodes.Return | nodes.Continue | nodes.Break | nodes.Raise | nodes.Callr   r   r  r  )r   )r   znodes.Break | nodes.Returnre  r;   rf  ztuple[nodes.NodeNG, ...]r  r  )r   z
nodes.Withr  r  )r   znodes.Assignr  r  )r  zlist[nodes.NodeNG | None]r  r  )r   z	nodes.Forr  r  )0r   r   r   r   r   msgsrN   reportsr   r   r   only_required_for_messagesr   r   r   r   staticmethodr   r   r   r   r  r  r  r  visit_asyncfunctiondefr  r+  r.  r4  r6  r<  rD  rJ  rQ  rU  r[  r^  r   r)  r*  rC  r  r  r  r  r  __classcell__)r   s   @r   rP   rP   f   s1   
 DY 
Y 	 
Y 	 
Y$ 	 
%Y4 	 
5Y@ 	 
AYP 	 
QYZ 	 
[Yj 	 
kYz 	 
{YJ 	 
KYX 	 
YYj 	 
kYx 	 
yYF 	 
GYP 	 
QYZ 	 
[Yh






gYDv .0DEGG$- &U%%E99 &U%%E99 &U%%E??
OU:OU "OU 
	OUb * *:43 &U%%'$!$>?>?@ '9	  
1
BE
	
 
 &U%%&:;7P <7Pr &U%%&?@, A, /&TP &U%%m5EF
I G
I &U%%m4& 5& &U%%m5EFL GL &U%%m4& 5&N* &U%%#==" &U%%&79ST
R U
R &U%%o6 7 &U%%&78 9Y "&T  
	4 57	#(# # 2	#
 
#27Er &U%%&@AL BL'R. &U%%!#=99 &U%%&@A: B:r   rP   )r@   zreporter_nodes.SectionrA   r   rB   zLinterStats | Noner  r  )(r   
__future__r   r  r   collections.abcr   typingr   r   r   r   r   r	   r
   pylintr   r9   pylint.checkersr   pylint.interfacesr   r   r   pylint.reporters.ureportsr>   pylint.utilsr   pylint.lint.pylinterr   r   rt  SEQUENCE_PROTOCOL_METHODSrv  r!   r  joinr$  rN   rP   )xs   0r   <module>r     s	  
 % "   $ / /  ( ( & . 9 9 = $-K  * 6 -0H/JK   ,CDq:q/	"D
 	
aS8 (&J
 &J&J "&J 
	&JTb:= b:y 	Es   7C
 C