
    ca                       d 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	m
Z
 ddlZddl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 ej        dk    rddlmZ nddlmZ  G d de          Z dZ!dZ"e"e!ffZ# e$ e%d dD             g d          fi d dD             Z&d#d Z' G d! d"e           Z(dS )$zBasic checker for Python code.    )annotationsN)Iterator)TYPE_CHECKINGcast)nodesobjects)utils)BaseCheckerr	   )HIGH	INFERENCE
Confidence)r   )LinterStats)PyLinter      )Literalc                      e Zd ZdZdZdS )_BasicCheckerzYPermits separating multiple checks with the same checker name into
    classes/file.
    basicN)__name__
__module____qualname____doc__name     Blib/python3.11/site-packages/pylint/checkers/base/basic_checker.pyr   r   !   s          DDDr   r   __reversed__)__getitem____len__c                <    g | ]}d                      d|g          S ).builtins)join.0xs     r   
<listcomp>r)   0   s(    DDDq:q/	"	"DDDr   )setdictlist)zset()z{}z[]c                    i | ]}|| d 	S )z()r   r&   s     r   
<dictcomp>r.   3   s0        	
a888  r   )zcollections.dequezcollections.ChainMapzcollections.Counterzcollections.OrderedDictzcollections.defaultdictzcollections.UserDictzcollections.UserListsectreporter_nodes.Sectionstatsr   	old_statsLinterStats | NonereturnNonec                (   i }dD ]}t          t          d         |          }|                    |          }i ||<   |dk    rY|                    |          }||z
  }|dz  |z  }|d||         d<   |                    |          }	|	dz  |z  }|d||         d<   g d}
dD ]}t          t          d         |          }|                    |          }|r|                    |          nd	}|rt          j        ||          nd	}|
|t          |          |rt          |          nd
|r|nd
||                             dd          ||                             dd          gz  }
| 	                    t          j        |
dd                     d	S )zzMake a report of.

    * percentage of different types documented
    * percentage of different types with a bad name
    )moduleclassmethodfunction)r:   r8   r9   r7   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)r/   r1   r2   
nice_stats	node_typetotalundocumented_node
documentedpercentbadname_nodelinesnewolddiff_strs                 r   report_by_type_statsr\   B   s    -/J> H H	!HI9UU	$$Y// "
9A: 	H % 6 6y A A!22J!E)U2G=D:J:JJy!"67 ..y99L#e+u4G:A7G7GJy!"34UUUE> 
 
	!HI9UU	""9--5>Hi&&y111D7:D:)#s333HH%CHHH *HHdy!%%&:C@@y!%%&7==
 	
 	KK$e!aHHHIIII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*Zd+d,effZd fd1Zdd2Z	 e
j        d3d4          dd7            Z e
j        d3d4          dd9            Z e
j        d3d4          dd;            Zdd?ZeddB            ZddEZddGZ e
j        dHdIdJdKdL          ddN            ZeddS            ZeddY            Z e
j        dZ          dd[            Z e
j        d\          dd^            ZeZdd_Z e
j        d`da          ddc            Z e
j        d`          dde            Z e
j        d`da          ddg            Z e
j        d`          ddi            ZddlZ e
j        dmdndodpd`          ddq            Z  e
j        drds          ddu            Z! e
j        dv          ddx            Z" e
j        dy          dd{            Z#dd}Z$dd~Z%e&fddZ'	 dddZ(ddZ) e
j        d          dd            Z*ddZ+ddZ, e
j        dd          dd            Z- e
j        d          dd            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.)E0119W0129W0130W0131W0133RP0101zStatistics by typelinterr   r4   r5   c                X    t                                          |           d | _        d S N)super__init___tryfinallys)selfr   	__class__s     r   r   zBasicChecker.__init__  s)       ;?r   c                    | j         j        j        }|dk    | _        g | _        | j         j                                         dS )z*Initialize visit variables and statistics.r   N)r   config
py_version
_py38_plusr   r1   reset_node_count)r   r   s     r   openzBasicChecker.open  s@    ['2
$.**,,,,,r   rx   rz   nodenodes.Ifc                <    |                      ||j                   d S r   _check_using_constant_testtestr   r   s     r   visit_ifzBasicChecker.visit_if  "     	''di88888r   nodes.IfExpc                <    |                      ||j                   d S r   r   r   s     r   visit_ifexpzBasicChecker.visit_ifexp!  r   r   nodes.Comprehensionc                X    |j         r |j         D ]}|                     ||           d S d S r   )ifsr   )r   r   if_tests      r   visit_comprehensionz BasicChecker.visit_comprehension'  sL     8 	?8 ? ?//g>>>>	? 	?? ?r   ,nodes.If | nodes.IfExp | nodes.Comprehensionr   nodes.NodeNG | Nonec           	     R   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        f|z   |z             }d }t)          ||          sZt-          j        |          }|t          j        u r7t)          |t           j                  rt4                              |          \  }}nt)          |t           j                  r|}|rt-          j        |j                  }	t)          |	t           j                  r_d }
|	                                D ]'}t)          |j        t           j                  sd}
 nd}
(|
r|                     d|t@                     d S |r|                     d|t@                     d S t)          ||          rd }	 t)          |t           j                  r|!                                }n/t)          |t           j                  r|!                    |          }n# t          j"        $ r d }Y nw xY w|rK	 |D ]1}|t          j        k    r|                     d|t@                      n2n# t          j"        $ r Y nw xY w|                     d|t@                     d S d S )NFTrx   r   
confidencerz   )#r   ModuleGeneratorExpLambdaFunctionDefClassDefastroidbases	GeneratorUnboundMethodBoundMethodDictTupleSetListCallBinOpBoolOpUnaryOp	Subscript
isinstanceConstr	   
safe_inferUninferableNamer^   _name_holds_generatorfunc _get_return_nodes_skip_functionsvalueadd_messager   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_inferredinf_calls                 r   r   z'BasicChecker._check_using_constant_test/  sI    LLNM#!L

 :u{EIuzB
 JKLMO
 $ 8; FGG#$-- 	('--H7.. V:dEJ3O3O V-9-O-OPT-U-U** ej)) 	(#'  	!,-A-FGGM-):;;  .2*#0#Q#Q#S#S 6 6K%k&79KLL 5:215..- $$-DY %    F 	U2)TTTTT+.. 	U !M%h(9:: E$,$>$>$@$@MM%,77 E$,$>$>t$D$DM) % % % $% 
$1 " "#w':: " ,, F%)+4 -   
 "E" -   D2)TTTTT/	U 	Us%   AJ$ $J87J8>4K3 3LL
nodes.Nametuple[bool, nodes.Call | None]c                ^   t          | t          j                  sJ d}d}|                     d                              | j                  }|s||fS d |d         D             }t          |d          }|t          t          j	        |f|                    rd}nt          |d                   dk    rst          |d         d         j        t          j                  rHt          |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.
        FNTfuturec              3     K   | ]G}t          |j        t          j                  !t          |j        j        t          j                  V  Hd S r   )r   parentr   Assignr   r   )r'   assign_names     r   	<genexpr>z5BasicChecker._name_holds_generator.<locals>.<genexpr>  s^       $
 $
+,el;;$
{)/1CDD$
 $
 $
 $
 $
 $
r   rC   r   )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  sN   
 $
+++++#

$
//66tyAA 	.---$
 $
,Q/$
 $
 $
 
 2D99
 
	H9?J=2JKKLL H M!$%%*H}Q/295<HHH }Q/29?LLH
 (5Q'7':'A'G$)))r   _nodes.Modulec                D    | j         j        j        dxx         dz  cc<   dS )z4Check module name, docstring and required arguments.r7   rC   Nr   r1   
node_countr   r   s     r   visit_modulezBasicChecker.visit_module  s,    $X...!3.....r   nodes.ClassDefc                D    | j         j        j        dxx         dz  cc<   dS )zXCheck module name, docstring and redefinition
        increment branch counter.
        klassrC   Nr   r   s     r   visit_classdefzBasicChecker.visit_classdef  s.     	$W---2-----r   rd   r   rf   rh   r   
nodes.Exprc                8   |j         }t          |t          j                  rt          |j         t                    r|                                }t          |t          j        t          j        t          j        f          rzt          |t          j                  r|j	        dk    rnT|
                                }|>|                                |u r(t          |t          j        t          j        f          rdS |                     d|           dS t          |t          j                  rd}t          |j        t          j                  r|j        j	        }n+t          |j        t          j                  r|j        j        }|dd                                         rt)          j        |          nd}t          |t,          j                  r|                     d|t0                     dS t          |t          j        t          j        f          sXt          |j        t          j                  r|j        j        |gk    s(t          |t          j                  r|j         t<          u rdS t          |t          j                  r|                     d	|t@                     dS tC          |"                    t          j                            r,|                     d
||#                                           dS |                     d|           dS )z4Check for various kind of statements without effect.r   Nrf   r    rC   r   r   r   rh   r   argsrd   )$r   r   r   r   rL   scoper   r   r   r   previous_siblingr   	AnnAssignr   r   r   r   	Attributeattrnameisupperr	   r   r   ExceptionInstancer   YieldAwaitr   	TryExceptbodyEllipsis	NamedExprr   anynodes_of_class	as_string)r   r   exprr   siblingr   r   s          r   
visit_exprzBasicChecker.visit_expr  s    zdEK(( 	Z
C-H-H 	
 JJLLE%%.%,@Q!RSS 
eU%677 	EJ*<T 	"3355G#MMOOu4 'wu0OPP
 9EEEF dEJ'' 	D$)UZ00 *y~DIu77 *y)
 26bqb1A1A1C1CMu'---H(G$=>>   3$9 !    F tek5;788	4;88	=A[=MRVQW=W	 4--	 37*2H	
 FdEO,, 	?9QUVVVVV$$UZ0011 	?)4>>;K;K       2>>>>>r   nodes.Lambda	call_argslist[nodes.NodeNG]Iterator[nodes.NodeNG]c              #     K   |D ]^}t          |t          j                  r>t          |j        t          j                  r|j        j        | j        j        k    r|V  Z|V  _d S r   )r   r   Starredr   r   r   r   vararg)r   r  args      r   _filter_varargzBasicChecker._filter_vararg  sx        	 	C#u}-- sy%*55	$)*:: III					 	r   r   #list[nodes.Starred | nodes.Keyword]variadic_namerL   boolc                @    |  pt          fd| D                       S )Nc              3     K   | ]S}t          |j        t          j                  r|j        j        k    pt          |j        t          j                   V  Td S r   )r   r   r   r   r   )r'   ar  s     r   r   z6BasicChecker._has_variadic_argument.<locals>.<genexpr>  sq       
 
  qw
++ .-3aguz222
 
 
 
 
 
r   )r  )r   r  s    `r   _has_variadic_argumentz#BasicChecker._has_variadic_argument  sH     x 
3 
 
 
 
 	
 
 
 
 
 	
r   rj   c                   |j         j        rdS |j        }t          |t          j                  sdS t          |j        j        t          j                  r+t          |j        j        j        t          j                  rdS t          j
        j                            |          }t          |j         j                   }t          |                     ||j                             }|j         j        r'|                     |j        |j         j                  rdS |j         j        r(|                     |j        |j         j                  rdS n	|j        rdS |j        rfd |j         j        D             }t+          |          t+          |j                  k    rdS t/          |j                                      |          rdS t+          |          t+          |          k    rdS t3          ||          D ]5\  }}t          |t          j                  s dS |j        |j        k    r dS 6|                     d|j        |           dS )z'Check whether the lambda is suspicious.Nc                    h | ]	}|j         
S r   )r   )r'   keywords     r   	<setcomp>z,BasicChecker.visit_lambda.<locals>.<setcomp>2  s    LLLgW\LLLr   rj   )liner   )r   defaultsr	  r   r   r   r   r  r  r   	argumentsCallSite	from_callr,   r  kwargr!  kwargsr  starargskeywordsr   keyword_argumentsr*   r?   zipr   r   r   
fromlineno)	r   r   call	call_siteordinary_argsnew_call_argslambda_kwargsr  
passed_args	            r   visit_lambdazBasicChecker.visit_lambda	  sD    9 	 Fy$
++ 	 Fdineo66 	:IN<
 <
 	
 F%.88>>	TY^,,T00tyAABB9? 	**4;	HH 9 	**4=$):JKK ] 	F= 	 ML9KLLLM=!!S)D%E%EE 9.//::=II  }]!3!33 	F"=-@@ 	 	OCj%*55 x:?*  	-DO$OOOOOr   rb   nodes.FunctionDefc                    |                                 r | j        j        j        dxx         dz  cc<   n| j        j        j        dxx         dz  cc<   |                     |           dS )zeCheck function name, docstring, arguments, redefinition,
        variable names, max locals.
        r9   rC   r:   N)	is_methodr   r1   r   _check_dangerous_defaultr   s     r   visit_functiondefzBasicChecker.visit_functiondefE  s{    
 >> 	:K(222a72222K(4449444%%d+++++r   c                z   dd}|j         j        pg |j         j        pg z   }|D ]}|s	 t          |                                          }n# t
          j        $ r Y :w xY wt          |t
          j                  r<|	                                t          v r ||u r t          |	                                         }nt          |t
          j                  s ||          r ||          r|                                }nt          |t          j                  r |j         d|	                                 d}nd|                                 d|	                                 d}n7|                                 dt          |	                                          d}|                     d	||f
           dS )z0Check for dangerous default values as arguments.internal_nodenodes.NodeNGr4   r  c                d    t          | t          j        t          j        t          j        f          S r   )r   r   r   r   r   )r?  s    r   is_iterablez:BasicChecker._check_dangerous_default.<locals>.is_iterableU  s    mej%)UZ-PQQQr   z() ()z (rb   r   N)r?  r@  r4   r  )r   r'  kw_defaultsr   inferr   r   r   InstanceqnameDEFAULT_ARGUMENT_SYMBOLSpytyper   r   r   r  r   )r   r   rB  r'  defaultr   msgs          r   r<  z%BasicChecker._check_dangerous_defaultR  s   	R 	R 	R 	R I&,"1F1L"M 	T 	TG W]]__--)    5'"233TKKMM%==T G# _25;;==ACCw'788 _KK<N<N _ #{7++ I#llnn#GUZ88 I!&AAAAA!(!2!2!4!4HHHHH %..00^^4LU[[]]4[^^^C  !:SF SSS?	T 	Ts   !AAAr`   rr   nodes.Returnc                t    |                      |           |                     |dt          j        f           dS )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
        r4   N)_check_unreachable_check_not_in_finallyr   r   r   s     r   visit_returnzBasicChecker.visit_returnz  s<     	%%%""4E4E3GHHHHHr   nodes.Continuec                0    |                      |           dS )z]Check is the node has a right sibling (if so, that's some unreachable
        code).
        NrN  r   s     r   visit_continuezBasicChecker.visit_continue      
 	%%%%%r   nodes.Breakc                    |                      |           |                     |dt          j        t          j        f           dS )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)rN  rO  r   ForWhiler   s     r   visit_breakzBasicChecker.visit_break  s?     	%%%""459ek2JKKKKKr   nodes.Raisec                0    |                      |           dS )z]Check if the node has a right sibling (if so, that's some unreachable
        code).
        NrS  r   s     r   visit_raisezBasicChecker.visit_raise  rU  r   	call_node
nodes.Callc                   t          |j        t          j                  sd S |j        j        dk    rd S t          j        |j        j                  }|t          j	        u rd S |sp|j        j        }t          |t          j
                  sd S t          |j        t          j                  r+|j        j        dk    r|                     d|           d S d S d S d S )Nformatprintr   r   )r   r   r   r  r  r	   r   r  r   r   r   r   r   r   )r   r_  r  	call_exprs       r    _check_misplaced_format_functionz-BasicChecker._check_misplaced_format_function  s    ).%/:: 	F>"h. 	F	 3447&& 	F 
	N "+Ii44 9>5:66NN'72N   !<9 MMMMM
	N 
	NN N N Nr   rp   rn   r   r   c                   t          j        |          r|                     |t                     |                     |           t          |j        t          j                  r|j        j	        }||
                    d          v ss||                                v s_|dk    r|                     d|           d
S |dk    r|                     |           d
S |dk    r|                     d	|           d
S d
S d
S d
S d
S )zVisit a Call node.)r   Tr   execrn   r   reversedevalrp   N)r	   is_terminating_funcrN  r   re  r   r   r   r   r   r   rootr   _check_reversed)r   r   r   s      r   
visit_callzBasicChecker.visit_call  s:    $T** 	@##DY#???--d333di,, 
	=9>D DJJdJ333 =ttyy{{7J =6> =$$[t$<<<<<Z' =((.....V^ =$$[t$<<<<<
	= 
	== = = =
= =r   rt   r   nodes.Assertc                   t          |j        t          j                  r:t	          |j        j                  dk    r|                     d|t                     t          |j        t          j                  rKt          |j        j	        t                    r.|j        j	        rd}nd}|                     d||f           dS dS dS )	z:Check whether assert is used on a tuple or string literal.r   rt   r   neveralwaysr   r   N)r   r   r   r   r   eltsr   r   r   r   rL   )r   r   whens      r   visit_assertzBasicChecker.visit_assert  s     di-- 	L#din2E2E2I 	L.TdKKKdi-- 	R*TY_c2R2R 	Ry  7d$QQQQQ	R 	R 	R 	Rr   rl   
nodes.Dictc                B   t                      }|j        D ]\  }}t          |t          j                  r|j        }n0t          |t          j                  r|                                }nW||v r|                     d||           |	                    |           dS )z"Check duplicate key in dictionary.rl   r   N)
r*   itemsr   r   r   r   r  r  r   add)r   r   keyskr   keys         r   
visit_dictzBasicChecker.visit_dict  s     uuJ 		 		DAq!U[)) gAu// kkmmd{ G  t# FFFHHSMMMM		 		r   r   	nodes.Setc                    t                      }|j        D ]\}t          |t          j                  r|j        }n%||v r|                     d||t                     |                    |           ]dS )zCheck duplicate value in set.r   )r   r   r   N)	r*   rr  r   r   r   r   r   r   rx  )r   r   valuesvr   s        r   	visit_setzBasicChecker.visit_set  s      		 		A!U[))    %Du !    JJu		 		r   nodes.TryFinallyc                L    | j         J | j                             |           dS zUpdate try...finally flag.N)r   rN   r   s     r   visit_tryfinallyzBasicChecker.visit_tryfinally  s.     ,,,  &&&&&r   c                J    | j         J | j                                          dS r  )r   popr   s     r   leave_tryfinallyzBasicChecker.leave_tryfinally   s,     ,,,r   Fnodes.Return | nodes.Continue | nodes.Break | nodes.Raise | nodes.Callr   r   c                <   |                                 }|t          |t          j                  rQt          |t          j                  r7t          |j        t          j                  r|                                 }|dS |                     d||           dS dS )zCheck unreachable code.Nr`   r   )next_siblingr   r   ReturnExprr   r  r   )r   r   r   unreachable_statements       r   rN  zBasicChecker._check_unreachable  s     !% 1 1 3 3  	4..	4ejAA	 4:EKHH	 )>(J(J(L(L%( F$9j      	 	r   r   nodes.Break | nodes.Return	node_namebreaker_classestuple[nodes.NodeNG, ...]c                    | j         sdS |j        }|}|r`t          ||          sRt          |d          r#||j        v r|                     d||           dS |}|j        }|rt          ||          NdS dS dS dS )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.
        N	finalbodyrr   r   )r   r   r   hasattrr  r   )r   r   r  r  _parent_nodes         r   rO  z"BasicChecker._check_not_in_finally  s       	F+ 	#j/BB 	#w,, ':K1K   !19 MMMElG  	#j/BB 	# 	# 	# 	# 	# 	# 	# 	# 	#r   c                   	 t          j        t          j        |d                    }|t          j        u rdS |t          |j        d         t          j                  r	 t          |j        d         j
                                                  }n# t          j        $ r Y dS w xY wt          |dd          dk    r+t          j        |          r|                     d|           dS t          |t          j        t          j        f          rdS | j        st          |t          j                  rt)          d t+          j        |j        f|j                                                  D                       r=	 |j        t4                    n'# t6          $ r |                     d|           Y nw xY wdS t9          |d	          rXt:          D ]5}|D ].}	 |                    |           # t          j        $ r Y  nw xY w n6|                     d|           dS dS |                     d|           dS # t           j        $ r Y dS w xY w)
z4Check that the argument to `reversed` is a sequence.r   )positionNr   iterr   r   c              3  T   K   | ]#}|j         d k    ot          j        |          V  $dS )r+   N)r   r	   is_builtin_object)r'   ancestors     r   r   z/BasicChecker._check_reversed.<locals>.<genexpr>R  sM          MV+Q0G0Q0Q     r   getattr) r	   r   get_argument_from_callr   r   r   r   r   r   r   r   rE  r   r  r  r   r   r   r   rF  r  r   r   _proxied	ancestorslocalsREVERSED_PROTOCOL_METHODKeyErrorr  REVERSED_METHODSNotFoundErrorNoSuchArgumentError)r   r   argumentr   methodsmeths         r   rl  zBasicChecker._check_reversed4  s   5	E'(DTTU(V(V(VWWH 7..   dilEJ77 M#DIaL$5$;$;$=$=>>"1   fd   M$)$;D$A$AM (()@t(LLL(UZ$=>> 
 ? z(G<L'M'M   $-O!*,h.?.I.I.K.K% %     
M (@AAA# M M M(()@t(LLLLLMFx++ E/ 	I 	IG '  "$,,T2222&4 " " "!EE"  " $$%<4$HHHHH    !8t DDDDDg ( 	 	 	DD	sG   (H< "1B B'&B'?F !F65F6G//HH<IIrv   
nodes.Withc                   |j         }|r}t          ||dd                    D ]f\  }}t          |d         t          j                  r?|d         7t          |d         t          j                  s|                     d|           ed S d S )NrC   r   rv   r   )rw  r0  r   r   
AssignNamer   r   )r   r   pairs	prev_pairpairs        r   
visit_withzBasicChecker.visit_withm  s     
 		L#&ueABBi#8#8 L L	4ilE,<== LGL,6tAw
,K,KL $$%?d$KKK		L 		LL Lr   nodes.Assignc                p   |                                 }|j        }g }|j        }t          |d         t          j                  r7t          |          dk    rd S |d         j        }t          |          dk    rd S t          |j        t          j	                  rt          |          dk    rd S |j        g}n_t          |j        t          j                  r@t          |j        j                  }t          |          |k    s|dk    rd S |j        j        }t          ||          D ]\  }}t          |t          j	                  s t          |t          j                  s;t          |t          j                  r
|j        |v r_|j        |j        k    r|                     d|j        f|           d S )Nr   rC   r|   r   r   )r   r  targetsr   r   r   r   rr  r   r   r0  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}  s    

|	,gaj%+.. 	7||q  ajoG7||q  dj%*-- 	(7||q  II
EK00 	(DJO,,I7||y( IN 
I #GY 7 7 	 	FHh
33 fe&677  %00 V[L5P {hm+   -V[N !   	 	r   r  list[nodes.NodeNG | None]c                >   | j         j        j        }|D ]}t          |t          j                  sg }|j        D ]}t          |t          j                  r|                     |g           3t          |t          j                  rE|j	        dk    r:|r|
                    |j	                  r  d S |                    |j	                   t          j        |          }|                                D ]$\  }}|dk    r|                     d|f|           %	d S )Nr   rC   r~   r  )r   r   dummy_variables_rgxr   r   r   rr  _check_redeclared_assign_namer  r   matchrN   collectionsCountermost_commonr   )	r   r  r  r  found_nameselementnamesr   counts	            r   r  z*BasicChecker._check_redeclared_assign_name  sM   "k0D 	 	Ffek22 K!; 5 5gu{33 566yAAAA)9:: 5w|s?R 5* /B/H/H/V/V &&w|444'44E$0022  e19 $$2$v %   	 	r   r|   r~   c                d    |                      |           |                     |j                   d S r   )r  r  r  r   s     r   visit_assignzBasicChecker.visit_assign  s4     	++D111**4<88888r   	nodes.Forc                <    |                      |j        g           d S r   )r  r  r   s     r   	visit_forzBasicChecker.visit_for  s     **DK=99999r   )r   r   r4   r5   )r4   r5   )r   r   r4   r5   )r   r   r4   r5   )r   r   r4   r5   )r   r   r   r   r4   r5   )r   r   r4   r   )r   r   r4   r5   )r   r   r4   r5   )r   r   r4   r5   )r   r  r  r  r4   r  )r   r  r  rL   r4   r  )r   r  r4   r5   )r   r9  r4   r5   )r   rL  r4   r5   )r   rQ  r4   r5   )r   rV  r4   r5   )r   r\  r4   r5   )r_  r`  r4   r5   )r   r`  r4   r5   )r   rn  r4   r5   )r   ru  r4   r5   )r   r}  r4   r5   )r   r  r4   r5   )r   r  r4   r5   )r   r  r   r   r4   r5   )r   )r   r  r  rL   r  r  r4   r5   )r   r  r4   r5   )r   r  r4   r5   )r  r  r4   r5   )r   r  r4   r5   )0r   r   r   r   r   msgsr\   reportsr   r   r	   only_required_for_messagesr   r   r   r   staticmethodr   r   r   r  r  r!  r8  r=  visit_asyncfunctiondefr<  rP  rT  r[  r^  re  rm  rt  r|  r  r  r  r   rN  rO  rl  r  r  r  r  r  __classcell__)r   s   @r   r^   r^   l   s       
 
 DR 
R 	 
R 	 
R$ 	 
%R4 	 
5R@ 	 
ARP 	 
QRZ 	 
[Rj 	 
kRz 	 
{RJ 	 
KRX 	 
YRj 	 
kRx 	 
yRD 	 
ERN 	 
ORX 	 
YRf





YR R RDh .0DEGG@ @ @ @ @ @- - - - &U%E 9 9 9 9 &U%E 9 9 9 9 &U%E ? ? ? ?
PU PU PU PUd * * * \*:4 4 4 43 3 3 3 &U%'$!$ <? <? <? <?|    \ 
 
 
 \
 &U%&:;;9P 9P 9P <;9Pv &U%&?@@, , , A@, /&T &T &T &TP &U%m5EFF
I 
I 
I GF
I &U%m44& & & 54& &U%m5EFFL L L GFL &U%m44& & & 54&N N N N* &U%# = = = =" &U%&79STT
R 
R 
R UT
R &U%o66   76 &U%&788   98' ' ' '
        "&    4 57	# # # # #27E 7E 7E 7Er &U%&@AAL L L BAL' ' ' 'R   . &U%!#= 9 9 9 9 &U%&@AA: : : BA: : : : :r   r^   )r/   r0   r1   r   r2   r3   r4   r5   ))r   
__future__r   r  r   syscollections.abcr   typingr   r   r   r   r   pylintr	   rJ   pylint.checkersr
   pylint.interfacesr   r   r   pylint.reporters.ureportsrO   pylint.utilsr   pylint.lint.pylinterr   version_infor   typing_extensionsr   r  SEQUENCE_PROTOCOL_METHODSr  r+   r0  rH  r\   r^   r   r   r   <module>r     sL  
 % $ " " " " " "         



 $ $ $ $ $ $ & & & & & & & &  " " " " " " " " & & & & & & . . . . . . . . 9 9 9 9 9 9 9 9 9 9 = = = = = = $ $ $ $ $ $ .------v *))))))    K    * 6 -0H/JK   4CDD,CDDD  
 
    (&J &J &J &JTZ: Z: Z: Z: Z:= Z: Z: Z: Z: Z:r   