Module implementing a checker for miscellaneous checks.
None |
BugBearVisitor | Class implementing a node visitor to check for various topics. |
DateTimeVisitor | Class implementing a node visitor to check datetime function calls. |
LoggingVisitor | Class implementing a node visitor to check logging statements. |
MiscellaneousChecker | Class implementing a checker for miscellaneous checks. |
NameFinder | Class to extract a name out of a tree of nodes. |
ReturnVisitor | Class implementing a node visitor to check return statements. |
SysVersionVisitor | Class implementing a node visitor to check the use of sys.version and sys.version_info. |
TextVisitor | Class implementing a node visitor for bytes and str instances. |
composeCallPath | Generator function to assemble the call path of a given node. |
Class implementing a node visitor to check for various topics.
NodeWindowSize |
None |
BugBearVisitor | Constructor |
__checkForM502 | Private method to check the use of *strip(). |
__checkForM507 | Private method to check for unused loop variables. |
visit | Public method to traverse a given AST node. |
visit_Assert | Public method to handle 'assert' statements. |
visit_Assign | Public method to handle assignments. |
visit_Attribute | Public method to handle attributes. |
visit_Call | Public method to handle a function call. |
visit_For | Public method to handle 'for' statements. |
visit_JoinedStr | Public method to handle f-string arguments. |
visit_UAdd | Public method to handle unary additions. |
None |
Constructor
Private method to check the use of *strip().
Private method to check for unused loop variables.
Public method to traverse a given AST node.
Public method to handle 'assert' statements.
Public method to handle assignments.
Public method to handle attributes.
Public method to handle a function call.
Public method to handle 'for' statements.
Public method to handle f-string arguments.
Public method to handle unary additions.
Class implementing a node visitor to check datetime function calls.
Note: This class is modelled after flake8_datetimez checker.
None |
None |
DateTimeVisitor | Constructor |
__getFromKeywords | Private method to get a keyword node given its name. |
visit_Call | Public method to handle a function call. |
None |
Constructor
Private method to get a keyword node given its name.
Public method to handle a function call.
Every datetime related function call is check for use of the naive variant (i.e. use without TZ info).
Class implementing a node visitor to check logging statements.
LoggingLevels |
None |
LoggingVisitor | Constructor |
__detectLoggingLevel | Private method to decide whether an AST Call is a logging call. |
__isFormatCall | Private method to check if a function call uses format. |
__withinExtraKeyword | Private method to check, if we are inside the extra keyword. |
__withinLoggingArgument | Private method to check, if we are inside a logging argument. |
__withinLoggingStatement | Private method to check, if we are inside a logging statement. |
visit_BinOp | Public method to handle binary operations while processing the first logging argument. |
visit_Call | Public method to handle a function call. |
visit_JoinedStr | Public method to handle f-string arguments. |
None |
Constructor
Private method to decide whether an AST Call is a logging call.
Private method to check if a function call uses format.
Private method to check, if we are inside the extra keyword.
Private method to check, if we are inside a logging argument.
Private method to check, if we are inside a logging statement.
Public method to handle binary operations while processing the first logging argument.
Public method to handle a function call.
Every logging statement and string format is expected to be a function call.
Public method to handle f-string arguments.
Class implementing a checker for miscellaneous checks.
BuiltinsWhiteList |
Codes |
FormatFieldRegex |
Formatter |
None |
MiscellaneousChecker | Constructor |
__checkBugBear | Private method for bugbear checks. |
__checkBuiltins | Private method to check, if built-ins are shadowed. |
__checkCoding | Private method to check the presence of a coding line and valid encodings. |
__checkCommentedCode | Private method to check for commented code. |
__checkComprehensions | Private method to check some comprehension related things. |
__checkCopyright | Private method to check the presence of a copyright statement. |
__checkDateTime | Private method to check use of naive datetime functions. |
__checkDictWithSortedKeys | Private method to check, if dictionary keys appear in sorted order. |
__checkFormatString | Private method to check string format strings. |
__checkFuture | Private method to check the __future__ imports. |
__checkGettext | Private method to check the 'gettext' import statement. |
__checkLineContinuation | Private method to check line continuation using backslash. |
__checkLogging | Private method to check logging statements. |
__checkMutableDefault | Private method to check for use of mutable types as default arguments. |
__checkPep3101 | Private method to check for old style string formatting. |
__checkPrintStatements | Private method to check for print statements. |
__checkReturn | Private method to check return statements. |
__checkSysVersion | Private method to check the use of sys.version and sys.version_info. |
__checkTuple | Private method to check for one element tuples. |
__dictShouldBeChecked | Private function to test, if the node should be checked. |
__error | Private method to record an issue. |
__generateTree | Private method to generate an AST for our source. |
__getCoding | Private method to get the defined coding of the source. |
__getFields | Private method to extract the format field information. |
__ignoreCode | Private method to check if the message code should be ignored. |
__reportInvalidSyntax | Private method to report a syntax error. |
run | Public method to check the given source against miscellaneous conditions. |
None |
Constructor
Private method for bugbear checks.
Private method to check, if built-ins are shadowed.
Private method to check the presence of a coding line and valid encodings.
Private method to check for commented code.
Private method to check some comprehension related things.
Private method to check the presence of a copyright statement.
Private method to check use of naive datetime functions.
Private method to check, if dictionary keys appear in sorted order.
Private method to check string format strings.
Private method to check the __future__ imports.
Private method to check the 'gettext' import statement.
Private method to check line continuation using backslash.
Private method to check logging statements.
Private method to check for use of mutable types as default arguments.
Private method to check for old style string formatting.
Private method to check for print statements.
Private method to check return statements.
Private method to check the use of sys.version and sys.version_info.
Private method to check for one element tuples.
Private function to test, if the node should be checked.
Private method to record an issue.
Private method to generate an AST for our source.
Private method to get the defined coding of the source.
Private method to extract the format field information.
Private method to check if the message code should be ignored.
Private method to report a syntax error.
Public method to check the given source against miscellaneous conditions.
Class to extract a name out of a tree of nodes.
None |
None |
NameFinder | Constructor |
getNames | Public method to return the extracted names and Name nodes. |
visit | Public method to traverse a given AST node. |
visit_Name | Public method to handle 'Name' nodes. |
None |
Constructor
Public method to return the extracted names and Name nodes.
Public method to traverse a given AST node.
Public method to handle 'Name' nodes.
Class implementing a node visitor to check return statements.
Assigns |
Refs |
Returns |
None |
ReturnVisitor | Constructor |
__checkFunction | Private method to check a function definition node. |
__checkImplicitReturn | Private method to check for an implicit return statement. |
__checkImplicitReturnValue | Private method to check for implicit return values. |
__checkUnnecessaryAssign | Private method to check for an unnecessary assign statement. |
__checkUnnecessaryReturnNone | Private method to check for an unnecessary 'return None' statement. |
__hasRefsBeforeNextAssign | Private method to check for references before a following assign statement. |
__isNone | Private method to check, if a node value is None. |
__resultExists | Private method to check the existance of a return result. |
__visitAssignTarget | Private method to handle an assign target node. |
__visitWithStack | Private method to traverse a given function node using a stack. |
assigns | Public method to get the Assign nodes. |
refs | Public method to get the References nodes. |
returns | Public method to get the Return nodes. |
visit_Assign | Public method to handle an assign node. |
visit_AsyncFunctionDef | Public method to handle a function definition. |
visit_FunctionDef | Public method to handle a function definition. |
visit_Name | Public method to handle a name node. |
visit_Return | Public method to handle a return node. |
None |
Constructor
Private method to check a function definition node.
Private method to check for an implicit return statement.
Private method to check for implicit return values.
Private method to check for an unnecessary assign statement.
Private method to check for an unnecessary 'return None' statement.
Private method to check for references before a following assign statement.
Private method to check, if a node value is None.
Private method to check the existance of a return result.
Private method to handle an assign target node.
Private method to traverse a given function node using a stack.
Public method to get the Assign nodes.
Public method to get the References nodes.
Public method to get the Return nodes.
Public method to handle an assign node.
Public method to handle a function definition.
Public method to handle a function definition.
Public method to handle a name node.
Public method to handle a return node.
Class implementing a node visitor to check the use of sys.version and sys.version_info.
Note: This class is modelled after flake8-2020 checker.
None |
None |
SysVersionVisitor | Constructor |
__isSys | Private method to check for a reference to sys attribute. |
__isSysVersionUpperSlice | Private method to check the upper slice of sys.version. |
visit_Attribute | Public method to handle an attribute. |
visit_Compare | Public method to handle a comparison. |
visit_ImportFrom | Public method to handle a from ... |
visit_Name | Public method to handle an name. |
visit_Subscript | Public method to handle a subscript. |
None |
Constructor
Private method to check for a reference to sys attribute.
Private method to check the upper slice of sys.version.
Public method to handle an attribute.
Public method to handle a comparison.
Public method to handle a from ... import ... statement.
Public method to handle an name.
Public method to handle a subscript.
Class implementing a node visitor for bytes and str instances.
It tries to detect docstrings as string of the first expression of each module, class or function.
None |
None |
TextVisitor | Constructor |
__addNode | Private method to add a node to our list of nodes. |
__visitBody | Private method to traverse the body of the node manually. |
__visitDefinition | Private method handling class and function definitions. |
visit_AsyncFunctionDef | Public method to handle an asynchronous function definition. |
visit_Bytes | Public method to record a bytes node. |
visit_Call | Public method to handle a function call. |
visit_ClassDef | Public method to handle a class definition. |
visit_Constant | Public method to handle constant nodes. |
visit_FunctionDef | Public method to handle a function definition. |
visit_Module | Public method to handle a module. |
visit_Str | Public method to record a string node. |
None |
Constructor
Private method to add a node to our list of nodes.
Private method to traverse the body of the node manually.
If the first node is an expression which contains a string or bytes it marks that as a docstring.
Private method handling class and function definitions.
Public method to handle an asynchronous function definition.
Public method to record a bytes node.
Public method to handle a function call.
Public method to handle a class definition.
Public method to handle constant nodes.
Public method to handle a function definition.
Public method to handle a module.
Public method to record a string node.
Generator function to assemble the call path of a given node.