Module implementing a node visitor checking for code that could be simplified.
None |
SimplifyNodeVisitor | Class to traverse the AST node tree and check for code that can be simplified. |
None |
Class to traverse the AST node tree and check for code that can be simplified.
None |
None |
SimplifyNodeVisitor | Constructor |
__bodyContainsContinue | Private method to check, if a list of statements contain a 'continue' statement. |
__check101 | Private method to check for duplicate isinstance() calls. |
__check102 | Private method to check for nested if statements without else blocks. |
__check103 | Private method to check for calls that wrap a condition to return a bool. |
__check104 | Private method to check for "iterate and yield" patterns. |
__check105 | Private method to check for "try-except-pass" patterns. |
__check106 | Private method to check for calls where an exception is raised in else. |
__check107 | Private method to check for calls where try/except and finally have 'return'. |
__check108 | Private method to check for if-elses which could be a ternary operator assignment. |
__check109 | Private method to check for multiple equalities with the same value are combined via "or". |
__check110_111 | Private method to check if any / all could be used. |
__check112 | Private method to check for non-capitalized calls to environment variables. |
__check113 | Private method to check for loops in which "enumerate" should be used. |
__check114 | Private method to check for alternative if clauses with identical bodies. |
__check115 | Private method to to check for places where open() is called without a context handler. |
__check116 | Private method to check for places with 3 or more consecutive if-statements with direct returns. |
__check117 | Private method to check for multiple with-statements with same scope. |
__check118 | Private method to check for usages of "key in dict.keys()". |
__check119 | Private method to check for classes that should be "dataclasses". |
__check120_121 | Private method to check for classes that inherit from object. |
__check122 | Private method to check for all if-blocks which only check if a key is in a dictionary. |
__check123 | Private method to check for complicated dictionary access with default value. |
__check181 | Private method to check for assignments that could be converted into an augmented assignment. |
__check182 | Private method to check for calls of type 'super()' that could be shortened to 'super()'. |
__check201 | Private method to check for calls where an unary 'not' is used for an unequality. |
__check202 | Private method to check for calls where an unary 'not' is used for an equality. |
__check203 | Private method to check for calls where an unary 'not' is used for an in-check. |
__check204 | Private method to check for calls of the type "not (a < b)". |
__check205 | Private method to check for calls of the type "not (a <= b)". |
__check206 | Private method to check for calls of the type "not (a > b)". |
__check207 | Private method to check for calls of the type "not (a >= b)". |
__check208 | Private method to check for calls of the type "not (not a)". |
__check211 | Private method to check for calls of the type "True if a else False". |
__check212 | Private method to check for calls of the type "False if a else True". |
__check213 | Private method to check for calls of the type "b if not a else a". |
__check221 | Private method to check for calls of the type "a and not a". |
__check222 | Private method to check for calls of the type "a or not a". |
__check223 | Private method to check for calls of the type "... |
__check224 | Private method to check for calls of the type "... |
__check301 | Private method to check for Yoda conditions. |
__check401 | Private method to check for bare boolean function arguments. |
__check402 | Private method to check for bare numeric function arguments. |
__check901 | Private method to check for unnecessary bool conversion. |
__check904 | Private method to check for dictionary initialization. |
__check905 | Private method to check for list initialization by splitting a string. |
__check906 | Private method to check for unnecessary nesting of os.path.join(). |
__check907 | Private method to check for Union type annotation with None. |
__check909 | Private method to check for reflexive assignments. |
__check910 | Private method to check for uses of 'dict.get(key, None)'. |
__check911 | Private method to check for the expression "zip(_.keys(), _.values())". |
__expressionUsesVariable | Private method to check, if a variable is used by an expression. |
__getDuplicatedIsinstanceCall | Private method to get a list of isinstance arguments which could be combined. |
__getIfBodyPairs | Private method to extract a list of pairs of test and body for an If node. |
__isConstantIncrease | Private method to check an expression for being a constant increase. |
__isExceptionCheck | Private method to check, if the node is checking an exception. |
__isSameBody | Private method check, if the given bodies are equivalent. |
__isSameExpression | Private method to check, if two expressions are equal. |
__isStatementEqual | Private method to check, if two statements are equal. |
__negateTest | Private method negate the given Compare node. |
getOsPathJoinArgs | |
visit_Assign | Public method to process an Assign node. |
visit_BoolOp | Public method to process a BoolOp node. |
visit_Call | Public method to process a Call node. |
visit_ClassDef | Public method to process a ClassDef node. |
visit_Compare | Public method to process a Compare node. |
visit_Expr | Public method to process an Expr node. |
visit_For | Public method to process a For node. |
visit_If | Public method to process an If node. |
visit_IfExp | Public method to process an IfExp node. |
visit_Subscript | Public method to process a Subscript node. |
visit_Try | Public method to process a Try node. |
visit_UnaryOp | Public method to process a UnaryOp node. |
visit_With | Public method to process a With node. |
None |
Constructor
Private method to check, if a list of statements contain a 'continue' statement.
Private method to check for duplicate isinstance() calls.
Private method to check for nested if statements without else blocks.
Private method to check for calls that wrap a condition to return a bool.
Private method to check for "iterate and yield" patterns.
Private method to check for "try-except-pass" patterns.
Private method to check for calls where an exception is raised in else.
Private method to check for calls where try/except and finally have 'return'.
Private method to check for if-elses which could be a ternary operator assignment.
Private method to check for multiple equalities with the same value are combined via "or".
Private method to check if any / all could be used.
Private method to check for non-capitalized calls to environment variables.
Private method to check for loops in which "enumerate" should be used.
Private method to check for alternative if clauses with identical bodies.
Private method to to check for places where open() is called without a context handler.
Private method to check for places with 3 or more consecutive if-statements with direct returns.
* Each if-statement must be a check for equality with the same variable * Each if-statement must just have a "return" * Else must also just have a return
Private method to check for multiple with-statements with same scope.
Private method to check for usages of "key in dict.keys()".
Private method to check for classes that should be "dataclasses".
Private method to check for classes that inherit from object.
Private method to check for all if-blocks which only check if a key is in a dictionary.
Private method to check for complicated dictionary access with default value.
Private method to check for assignments that could be converted into an augmented assignment.
Private method to check for calls of type 'super()' that could be shortened to 'super()'.
Private method to check for calls where an unary 'not' is used for an unequality.
Private method to check for calls where an unary 'not' is used for an equality.
Private method to check for calls where an unary 'not' is used for an in-check.
Private method to check for calls of the type "not (a < b)".
Private method to check for calls of the type "not (a <= b)".
Private method to check for calls of the type "not (a > b)".
Private method to check for calls of the type "not (a >= b)".
Private method to check for calls of the type "not (not a)".
Private method to check for calls of the type "True if a else False".
Private method to check for calls of the type "False if a else True".
Private method to check for calls of the type "b if not a else a".
Private method to check for calls of the type "a and not a".
Private method to check for calls of the type "a or not a".
Private method to check for calls of the type "... or True".
Private method to check for calls of the type "... and False".
Private method to check for Yoda conditions.
Private method to check for bare boolean function arguments.
Private method to check for bare numeric function arguments.
Private method to check for unnecessary bool conversion.
Private method to check for dictionary initialization.
Private method to check for list initialization by splitting a string.
Private method to check for unnecessary nesting of os.path.join().
Private method to check for Union type annotation with None.
Private method to check for reflexive assignments.
Private method to check for uses of 'dict.get(key, None)'.
Private method to check for the expression "zip(_.keys(), _.values())".
Private method to check, if a variable is used by an expression.
Private method to get a list of isinstance arguments which could be combined.
Private method to extract a list of pairs of test and body for an If node.
Private method to check an expression for being a constant increase.
Private method to check, if the node is checking an exception.
Private method check, if the given bodies are equivalent.
Private method to check, if two expressions are equal.
Private method to check, if two statements are equal.
Private method negate the given Compare node.
Public method to process an Assign node.
Public method to process a BoolOp node.
Public method to process a Call node.
Public method to process a ClassDef node.
Public method to process a Compare node.
Public method to process an Expr node.
Public method to process a For node.
Public method to process an If node.
Public method to process an IfExp node.
Public method to process a Subscript node.
Public method to process a Try node.
Public method to process a UnaryOp node.
Public method to process a With node.