eric7.Plugins.CheckerPlugins.CodeStyleChecker.Imports.ImportsChecker

Module implementing a checker for import statements.

Global Attributes

None

Classes

ImportsChecker Class implementing a checker for import statements.

Functions

None


ImportsChecker

Class implementing a checker for import statements.

Derived from

None

Class Attributes

Codes

Class Methods

None

Methods

ImportsChecker Constructor
__checkBannedImport Private method to check import of banned modules.
__checkBannedRelativeImports Private method to check if relative imports are banned.
__checkLocalImports Private method to check local imports.
__checkUnnecessaryAlias Private method to check unnecessary import aliases.
__compileUnstructuredGlob Private method to convert a pattern to a regex such that ".*" matches zero or more modules.
__error Private method to record an issue.
__ignoreCode Private method to check if the message code should be ignored.
__isModuleBanned Private method to check, if the given module name banned.
__tidyImports Private method to check various other import related topics.
run Public method to check the given source against miscellaneous conditions.

Static Methods

None

ImportsChecker (Constructor)

ImportsChecker(source, filename, tree, select, ignore, expected, repeat, args)

Constructor

source (list of str)
source code to be checked
filename (str)
name of the source file
tree (ast.Module)
AST tree of the source code
select (list of str)
list of selected codes
ignore (list of str)
list of codes to be ignored
expected (list of str)
list of expected codes
repeat (bool)
flag indicating to report each occurrence of a code
args (dict)
dictionary of arguments for the various checks

ImportsChecker.__checkBannedImport

__checkBannedImport(node)

Private method to check import of banned modules.

node (ast.AST)
reference to the node to be checked

ImportsChecker.__checkBannedRelativeImports

__checkBannedRelativeImports(node)

Private method to check if relative imports are banned.

node (ast.AST)
reference to the node to be checked

ImportsChecker.__checkLocalImports

__checkLocalImports()

Private method to check local imports.

ImportsChecker.__checkUnnecessaryAlias

__checkUnnecessaryAlias(node)

Private method to check unnecessary import aliases.

node (ast.AST)
reference to the node to be checked

ImportsChecker.__compileUnstructuredGlob

__compileUnstructuredGlob(module)

Private method to convert a pattern to a regex such that ".*" matches zero or more modules.

module (str)
module pattern to be converted
Return:
compiled regex
Return Type:
re.regex object

ImportsChecker.__error

__error(lineNumber, offset, code, *args)

Private method to record an issue.

lineNumber (int)
line number of the issue
offset (int)
position within line of the issue
code (str)
message code
args (list)
arguments for the message

ImportsChecker.__ignoreCode

__ignoreCode(code)

Private method to check if the message code should be ignored.

code (str)
message code to check for
Return:
flag indicating to ignore the given code
Return Type:
bool

ImportsChecker.__isModuleBanned

__isModuleBanned(moduleName)

Private method to check, if the given module name banned.

moduleName (str)
module name to be checked
Return:
flag indicating a banned module
Return Type:
bool

ImportsChecker.__tidyImports

__tidyImports()

Private method to check various other import related topics.

ImportsChecker.run

run()

Public method to check the given source against miscellaneous conditions.

Up