
    yIf                    ^   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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Literalcast)nodesobjectsutil)utils)BaseCheckerr   )HIGH	INFERENCE
Confidence)r   )LinterStats)PyLinterc                      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     V/var/www/piapp/venv/lib/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'   *   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,   -   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)r8   r6   r7   r5   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-   r/   r0   
nice_stats	node_typetotalundocumented_node
documentedpercentbadname_nodelinesnewolddiff_strs                 r   report_by_type_statsrZ   <   s    -/J> H H	!HI9UU	$$Y// "
9A:: % 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*d+Zd,d-effZd fd2Zdd3Z	 e
j        d4d5          dd8            Z e
j        d4d5          dd:            Z e
j        d4d5          dd<            Zdd@ZeddC            ZddFZddHZ e
j        dIdJdKdLdM          ddO            ZeddT            ZeddZ            Z e
j        d[          dd\            Z e
j        d]          dd_            ZeZdd`Z e
j        dadb          ddd            Z e
j        da          ddf            Z e
j        dadb          ddh            Z e
j        da          ddj            ZddmZ e
j        dndodpdqda          ddr            Z  e
j        dsdt          ddv            Z! e
j        dw          ddy            Z" e
j        dz          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.)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 typelinterr   r2   r3   c                N    t                                          |           |  d S N)super__init__)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.)      N)r   config
py_version
_py38_plus_trysr/   reset_node_count)r   r   s     r   openzBasicChecker.open  s?    ['2
$.
**,,,,,r   rv   rx   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           	     B   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||R           }d }t)          ||          sft-          j        |          }t)          |t0          j                  r7t)          |t           j                  rt6                              |          \  }}nt)          |t           j                  r|}|rt-          j        |j                  }	t)          |	t           j                  r_d }
|	                                D ]'}t)          |j        t           j                  sd}
 nd}
(|
r|                      d|tB                     d S |r|                      d|tB                     d S t)          ||          rd }	 t)          |t           j                  r#tE          |#                    |                    }n<t)          |t           j                  r"tE          |#                    |                    }n# t          j$        $ r d }Y nw xY w|r|                      d|tB                     |                      d|tB                     d S d S )NFTrv   r   
confidencerx   )%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Namer\   _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    LLNM#!L

 :u{EIuzB
 JKLMO
 $ Ew E E EFF#$-- 		('--H(D$899 Vjej? ? V .:-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:: K$()C)CD)I)I$J$JMM%,77 K$()C)CD)I)I$J$JM) % % % $%   :( !   
 2)TTTTT)	U 	Us   A9K
 
KK
nodes.Nametuple[bool, nodes.Call | None]c                Z   t          | t          j                  sJ 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.
        FNc              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   rA   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>   
 $
+++++#

++DI66 	.---$
 $
,Q/$
 $
 $
 
 2D99
!9?J=2JKKLL H M!$%%**}Q/295<HH +}Q/29?LL + (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.r5   rA   Nr   r/   
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.
        klassrA   Nr   r   s     r   visit_classdefzBasicChecker.visit_classdef  s.     	$W---2-----r   rb   r   rd   rf   r   
nodes.Exprc                f   |j         }t          |t          j                  rt          |j         t                    r|                                }t          |t          j        t          j        t          j        f          rt          |t          j                  r|j	        dk    rn_|
                                }|I|                                |u r3t          |t          j        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|t2                     dS t          |t          j        t          j        f          sdt          |j        t          j        t          j        f          r|j        j        |gk    s(t          |t          j                  r|j         t@          u rdS t          |t          j!                  r|                     d	|tD                     dS tG          |$                    t          j                            r,|                     d
||%                                           dS |                     d|           dS )z4Check for various kind of statements without effect.r   Nrd   r    rA   r   r   r   rf   r   argsrb   )&r   r   r   r   rJ   scoper   r   r   r   previous_siblingr   	AnnAssign	TypeAliasr   r   r   r   	Attributeattrnameisupperr   r   r	   ExceptionInstancer   YieldAwaitr   TryTryStar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<T"3355G+#MMOOu44&#elEOU_%U  5
 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;EM(BCC	 K$..4-- /26*2H2H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  st        	 	C#u}-- sy%*55	$)*:::III					 	r   r   #list[nodes.Starred | nodes.Keyword]variadic_namerJ   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   rh   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         j        r(|                     |j        |j         j                  rdS n	|j        rdS |j         j        r(|                     |j        |j         j                  rdS n	|j        rdS t!          |          t!          |          k    rdS t#          ||          D ]5\  }}t          |t          j                  s dS |j        |j        k    r dS 6|j                            t          j                  D ]'}|                    |j                  d         |u r dS (|                     d|j        |           dS )z'Check whether the lambda is suspicious.Nr   rh   )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    9 	 Fy$
++ 	 Fdineo66 	:IN<
 <
 	
 FTY^,,T00tyAABB9? 	**4=$)/JJ ] 	F9 	**4=$):JKK ] 	F }]!3!333F"=-@@ 	 	OCj%*55 x:?** + I,,UZ88 	 	D{{49%%a(D00 1 	-DO$OOOOOr   r`   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.
        r7   rA   r8   N)	is_methodr   r/   r   _check_dangerous_defaultr   s     r   visit_functiondefzBasicChecker.visit_functiondefH  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.NodeNGr2   r  c                d    t          | t          j        t          j        t          j        f          S r   )r   r   r   r   r   )r6  s    r   is_iterablez:BasicChecker._check_dangerous_default.<locals>.is_iterableX  s    mej%)UZ-PQQQr   z() ()z (r`   r   N)r6  r7  r2   r  )r   r%  kw_defaultsr   inferr   r   r   InstanceqnameDEFAULT_ARGUMENT_SYMBOLSpytyper   r   r   r  r   )r   r   r9  r%  defaultr   msgs          r   r3  z%BasicChecker._check_dangerous_defaultU  s   	R 	R 	R 	R I&,"1F1L"M 	T 	TG W]]__--)    5'"233TKKMM%===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^   rp   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
        r2   N)_check_unreachable_check_not_in_finallyr   r   r   s     r   visit_returnzBasicChecker.visit_return}  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rE  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)rE  rF  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).
        NrJ  r   s     r   visit_raisezBasicChecker.visit_raise  rL  r   	call_node
nodes.Callc                   t          |j        t          j                  sd S |j        j        dk    rd S t          j        |j        j                  }t          |t          j	                  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   rV  r  	call_exprs       r    _check_misplaced_format_functionz-BasicChecker._check_misplaced_format_function  s    ).%/:: 	F>"h..F	 344dD011 	F 
	N "+Ii44 9>5:66NN'722  !<9 MMMMM
	N 
	NN N22r   rn   rl   r~   r   c                    t          j        |          r|                     |t                     |                     |           t          |j        t          j                  r|j        j	        }||
                                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   execrl   r   reversedevalrn   N)r   is_terminating_funcrE  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33di,, 
	=9>D DJJLL((DDIIKK,?,?6>>$$[t$<<<<<Z''((.....V^^$$[t$<<<<<
	= 
	= )(,?,?
 $^r   rr   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   rr   r   neveralwaysr   r   N)r   r   r   r   r   eltsr   r   r   r   rJ   )r   r   whens      r   visit_assertzBasicChecker.visit_assert  s     di-- 	L#din2E2E2I2I.TdKKKdi-- 	R*TY_c2R2R 	Ry  7d$QQQQQ	R 	R 	R 	Rr   rj   
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.rj   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{{  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(   ri  r   r   r   r   r   r   ro  )r   r   valuesvr   s        r   	visit_setzBasicChecker.visit_set  s      		 		A!U[))   %Du !    JJu		 		r   	nodes.Tryc                    | j                             |           |j        D ]A}|                    t          j                  D ]}|                     d|t                      BdS )Update try block flag.r   r   N)r   rL   	finalbodyr  r   Returnr   r   )r   r   
final_noder   s       r   	visit_tryzBasicChecker.visit_try  s~    
$. 	Y 	YJ)88FF Y Y  !4;SW XXXXY	Y 	Yr   c                8    | j                                          dS )r{  N)r   popr   s     r   	leave_tryzBasicChecker.leave_try  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   r}  Exprr   r  r   )r   r   r   unreachable_statements       r   rE  zBasicChecker._check_unreachable
  s     !% 1 1 3 3 ,4..	4ejAA	 4:EKHH	 )>(J(J(L(L%(0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.
        Nr|  rp   r   )r   r   r   hasattrr|  r   )r   r   r  r  _parent_nodes         r   rF  z"BasicChecker._check_not_in_finally   s     z 	F+ 	#j/BB 	#w,, ':K1K1K  !19 MMMElG  	#j/BB 	# 	# 	# 	# 	# 	# 	# 	# 	#r   c                   	 t          j        t          j        |d                    }t          |t          j                  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        t6                    n'# t8          $ r |                     d|           Y nw xY wdS t;          |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>W  sM          MV+Q0G0Q0Q     r   getattr)!r   r   get_argument_from_callr   r
   r   r   r   r   r   r   r<  r   r   r  r  r   r   r   r   r=  r  r   r   _proxied	ancestorslocalsREVERSED_PROTOCOL_METHODKeyErrorr  REVERSED_METHODSNotFoundErrorNoSuchArgumentError)r   r   argumentr   methodsmeths         r   rc  zBasicChecker._check_reversed9  s   5	E'(DTTU(V(V(VWWH (D$899  dilEJ77 M#DIaL$5$;$;$=$=>>"1   fd    $)$;D$A$A  (()@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   (I .1B   B32B3F !GG%G;;HHIIrt   
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 )NrA   r   rt   r   )rn  r)  r   r   
AssignNamer   r   )r   r   pairs	prev_pairpairs        r   
visit_withzBasicChecker.visit_withr  s     
 		L#&ueABBi#8#8 L L	4ilE,<== LGOJtAw
,K,KO $$%?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   rA   rz   r   r   )r   r  targetsr   r   r   r   ri  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  s    

|	,gaj%+.. 	7||q  ajoG7||q  dj%*-- 	(7||q  II
EK00 	(DJO,,I7||y((INN
I #GY 7 7 	 	FHh
33 fe&677  %00 V[L5P5P{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   rA   r|   r  )r   r   dummy_variables_rgxr   r   r   ri  _check_redeclared_assign_namer  r   matchrL   collectionsCountermost_commonr   )	r   r  r  r  found_nameselementnamesr   counts	            r   r  z*BasicChecker._check_redeclared_assign_name  sH   "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?R* /B/H/H/V/V &&w|444'44E$0022  e199$$2$v %   	 	r   rz   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   r2   r3   )r2   r3   )r   r   r2   r3   )r   r   r2   r3   )r   r   r2   r3   )r   r   r   r   r2   r3   )r   r   r2   r   )r   r   r2   r3   )r   r   r2   r3   )r   r   r2   r3   )r   r  r  r  r2   r  )r   r  r  rJ   r2   r  )r   r  r2   r3   )r   r0  r2   r3   )r   rC  r2   r3   )r   rH  r2   r3   )r   rM  r2   r3   )r   rS  r2   r3   )rV  rW  r2   r3   )r   rW  r2   r3   )r   re  r2   r3   )r   rl  r2   r3   )r   rt  r2   r3   )r   ry  r2   r3   )r   ry  r2   r3   )r   r  r   r   r2   r3   )r   )r   r  r  rJ   r  r  r2   r3   )r   r  r2   r3   )r   r  r2   r3   )r  r  r2   r3   )r   r  r2   r3   )0r   r   r   r   r   msgsrZ   reportsr   r   r   only_required_for_messagesr   r   r   r   staticmethodr   r   r   r  r  r"  r/  r4  visit_asyncfunctiondefr3  rG  rK  rR  rU  r\  rd  rk  rs  rx  r  r  r   rE  rF  rc  r  r  r  r  r  __classcell__)r   s   @r   r\   r\   f   s       
 
 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 Y YDv .0DEGG$ $ $ $ $ $- - - - &U%E 9 9 9 9 &U%E 9 9 9 9 &U%E ? ? ? ?
OU OU OU OUb * * * \*:4 4 4 43 3 3 3 &U%'$!$ A? A? A? A?F    \ 
 
 
 \
 &U%&:;;7P 7P 7P <;7Pr &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Y Y Y Y    "&    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-   r.   r/   r   r0   r1   r2   r3   )'r   
__future__r   r  r   collections.abcr   typingr   r   r   r   r   r	   r
   pylintr   rH   pylint.checkersr   pylint.interfacesr   r   r   pylint.reporters.ureportsrM   pylint.utilsr   pylint.lint.pylinterr   r   r  SEQUENCE_PROTOCOL_METHODSr  r)   r)  r?  rZ   r\   r   r   r   <module>r     s  
 % $ " " " " " "         $ $ $ $ $ $ / / / / / / / / / /  ( ( ( ( ( ( ( ( ( ( & & & & & & . . . . . . . . 9 9 9 9 9 9 9 9 9 9 = = = = = = $ $ $ $ $ $ .------    K    * 6 -0H/JK   4CDD,CDDD  
 
    (&J &J &J &JTe: e: e: e: e:= e: e: e: e: e:r   