bg ddlmZddlmZddlmZmZddlmZddl m Z ddl m Z ddl mZddlmZerdd lmZGd d e ZddZdS)) annotations) TYPE_CHECKING)Instancenodes)UninferableBase) BaseChecker) safe_infer)DUNDER_METHODS)HIGH)PyLintercNeZdZdZdZdZddiZdZdd Ze dd Z ddZ dS)DunderCallCheckeraCheck for unnecessary dunder method calls. Docs: https://docs.python.org/3/reference/datamodel.html#basic-customization We exclude names in list pylint.constants.EXTRA_DUNDER_METHODS such as __index__ (see https://github.com/PyCQA/pylint/issues/6795) since these either have no alternative method of being called or have a genuine use case for being called manually. Additionally, we exclude classes that are not instantiated since these might be used to access the dunder methods of a base class of an instance. We also exclude dunder method calls on super() since these can't be written in an alternative manner. unnecessary-dunder-callC2801)z)Unnecessarily calls dunder method %s. %s.rziUsed when a dunder method is manually called instead of using the corresponding function/method/operator.returnNoneci|_tjD]4\}}||jjjkr|j|5dSN)_dunder_methodsr itemslinterconfig py_versionupdate)self since_versdunder_methodss o/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/checkers/dunder_methods.pyopenzDunderCallChecker.open0s\/1*8*>*@*@ < < &JT[/:::$++N;;; < <node nodes.NodeNGboolc|j}|Yt|tjr6|jdr|jdrdS|j}|YdS)zACheck if dunder method call is within a dunder method definition.N__TF)parent isinstancer FunctionDefname startswithendswith)r#r(s r within_dunder_defz#DunderCallChecker.within_dunder_def6su 65#455 K**400 K((..  t]F ur" nodes.Callcdt|jtjr |jj|jvr||st|jjtjrCt|jjjtj r|jjjj dkst|jj}|t|ttfsdS|d||jj|j|jjftdSdSdSdSdS)z=Check if method being called is an unnecessary dunder method.superNr)r#args confidence)r)funcr Attributeattrnamerr.exprCallNamer+r rr add_messager )rr#inf_exprs r visit_callzDunderCallChecker.visit_callDs- ty%/ 2 2  "d&:::**400;49>5:66;ty~2EJ?? ; IN',77"$).11H Jx(O9T$U$U    )i($*>ty?Q*RS      #  :::: 87r"N)rr)r#r$rr%)r#r/rr) __name__ __module__ __qualname____doc__r+prioritymsgsoptionsr! staticmethodr.r<rr"r rrs   %DH  DG<<<<    \ r"rrr rrcJ|t|dSr)register_checkerr)rs r registerrG_s% -f5566666r"N)rr rr) __future__rtypingrastroidrr astroid.utilrpylint.checkersrpylint.checkers.utilsr pylint.constantsr pylint.interfacesr pylint.lintr rrGrr"r rQs #""""" ########(((((('''''',,,,,,++++++""""""%$$$$$$GGGGG GGGT777777r"