bgHdZddlmZddlmZddlmZmZmZm Z ddl m Z ddl m Zddl mZddlmZdd lmZdd lmZerdd lmZe e je je je je je je je j e j!e j"e j#e j$e j%e j&e j'e j(fZ)e e j*e j+e j,e j-fZ.ed e e)e j-e j/f Z0GddeZ GddeZGddej1Z2ddZ3dS)z.Module to add McCabe checker class for pylint.) annotations)Sequence) TYPE_CHECKINGAnyTypeVarUnion)nodes) PathGraph)PathGraphingAstVisitor)checkers)only_required_for_messages)HIGH)PyLinter_AppendableNodeT)boundc eZdZdfd ZxZS)r node"_SubGraphNodes | nodes.FunctionDefc^tddd||_dS)N)nameentitylineno)super__init__root)selfr __class__s i/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/extensions/mccabe.pyrzPathGraph.__init__1s- bA666 )rr)__name__ __module__ __qualname__r __classcell__rs@r r r 0s=r!r ceZdZdfd ZddZdd Zdd ZeZd d ZexZ xZ xZ xZ xZ xZxZxZxZxZxZxZxZxZxZZd!dZeZd"dZ d#d$dZd%dZxZS)&r returnNonecdtd|_d|_dS)Nr)rr_bottom_countergraph)rrs r rzPathGraphingAstVisitor.__init__7s,  '+ r!r nodes.NodeNGargsrcP|D]}|j|g|RdSN) get_childrendispatch)rrr.childs r defaultzPathGraphingAstVisitor.default<sD&&(( ( (E DM% '$ ' ' ' ' ' ( (r!c||_|j}|j|}|/|j}t |jd|z|j}||j|<||g|RS)Nvisit)rr_cachegetr"getattrvisitorr4)rrr.klassmeth class_names r r2zPathGraphingAstVisitor.dispatch@sm {u%% <J4<:)=t|LLD!%DK tD 4    r!nodes.FunctionDefc|j||}||_||j|j}|xjdz c_|j|j||j||||_dSt||_||_||j|j|j|j |j <| dS)Nr) r, _append_nodetail dispatch_listbodyr+connectr graphs classnamerreset)rrpathnodebottoms r visitFunctionDefz'PathGraphingAstVisitor.visitFunctionDefJs : !((..H DI   ty ) ) ),.F  A % J  ty& 1 1 1 J  tV , , ,DIII"4DJDI   ty ) ) ):>*DK4>64966 7 JJLLLLLr!_StatementNodesc0||dSr0)r@rrs r visitSimpleStatementz+PathGraphingAstVisitor.visitSimpleStatement^s $r! nodes.Withcd||||jdSr0)r@rBrCrMs r visitWithz PathGraphingAstVisitor.visitWithys2 $ 49%%%%%r!r_AppendableNodeT | Nonect|jr|jsdS|j|j|||_|Sr0)rAr,rDrMs r r@z#PathGraphingAstVisitor._append_nodes@y   4 49d+++  r!_SubGraphNodesrstr extra_blocksSequence[nodes.ExceptHandler]c|jYt||_|||||j|j|j|<|dS||||||dS)z@Create the subgraphs representing any `if` and `for` statements.N)r,r _subgraph_parserErFrGr@)rrrrWs r _subgraphz PathGraphingAstVisitor._subgraphs : "4DJ  t\ : : :59ZDK4>1411 2 JJLLLLL   d # # #  t\ : : : : :r!rHcHg}||_||j||j|D]=}||_||j||j>|jr<||_||j||jn|||rH|jrC|j}|xjdz c_|D]}|j||||_dSdSdS)zAParse the body and any `else` block of `if` and `for` statements.rN)rArBrCappendorelser,r+rD)rrrHrW loose_endsextrarIends r rZz&PathGraphingAstVisitor._subgraph_parsesN   49%%%$)$$$! ) )EDI   uz * * *   di ( ( ( ( ; $DI   t{ + + +   di ( ( ( (   d # # #  DJ ,.F  A % ! 0 0 ""3////DIII     r!)r(r))rr-r.rr(r))rr-r.rr(r)rr>r(r))rrKr(r))rrOr(r))rrr(rR)rT)rrUrrVrWrXr(r))rrUrHrUrWrXr(r))r"r#r$rr4r2rJvisitAsyncFunctionDefrN visitAssert visitAssignvisitAugAssign visitDelete visitRaise visitYield visitImport visitCallvisitSubscript visitPass visitContinue visitBreak visitGlobal visitReturn visitExpr visitAwaitrQvisitAsyncWithr@r[rZr%r&s@r r r 6s,,,,,, ((((!!!!$-    2>R-RKRR R  R R R R R R" #R& 'R* +R, -R,"-R,%. &&&&N79 ;;;;;"r!r c\eZdZdZdZddiZddddd d ffZed ddZdS)McCabeMethodCheckerzoChecks McCabe complexity cyclomatic threshold in methods and functions to validate a too complex code. designR1260)z*%s is too complex. The McCabe rating is %d too-complexzSUsed when a method or function is too complex based on McCabe Complexity Cyclomaticzmax-complexity intzz&McCabe complexity cyclomatic threshold)r4typemetavarhelprxr nodes.Moduler(r)ct}|jD]}||||jD]}|}|j}t|dr d|jd}n"d|j j d}||j j jkrq|d|t ||fdS)zVisit an astroid.Module node to check too complex rating and add message if is greater than max_complexity stored from options. r'zThis 'rx)r confidencer.N)r rCpreorderrEvalues complexityrhasattrrrr"lowerlinterconfigmax_complexity add_messager)rrr:r3r,r node_names r visit_modulez McCabeMethodChecker.visit_modules )**Y - -E   UG , , , ,^**,,  E))++J:DtV$$ H, ,,, GT^%<%B%B%D%DGGG T[/>>>   DTJ@W       r!N)rr~r(r)) r"r#r$__doc__rmsgsoptionsr rrTr!r rurus D   D "@     G  ../.r!rurrr(r)cJ|t|dSr0)register_checkerru)rs r registerrs% /7788888r!N)rrr(r))4r __future__rcollections.abcrtypingrrrrastroidr mccaber Mccabe_PathGraphr Mccabe_PathGraphingAstVisitorpylintr pylint.checkers.utilsr pylint.interfacesr pylint.lintrAssertAssign AugAssignDeleteRaiseYieldImportCall SubscriptPassContinueBreakGlobalReturnExprAwaitrKIf TryExceptForWhilerU FunctionDefr BaseCheckerrurrTr!r rs/ 54""""""$$$$$$555555555555000000JJJJJJ<<<<<<""""""%$$$$$$ L L O L K K L J O J N K L L J K&ux%)U[HI7eOU[%BS$ST   {{{{{:{{{|.....(....b999999r!