class documentation

BaseChecker for import statements. Checks for * external modules dependencies * relative / wildcard imports * cyclic imports * uses of deprecated modules * uses of modules instead of preferred modules

Method __init__ Checker instances should have the linter as argument.
Method close Called before visiting project (i.e set of modules).
Method compute_first_non_import_node Undocumented
Method deprecated_modules Callback returning the deprecated modules.
Method leave_module Undocumented
Method open Called before visiting project (i.e set of modules).
Method visit_functiondef Undocumented
Method visit_import Triggered when an import statement is seen.
Method visit_importfrom Triggered when a from statement is seen.
Method visit_module Store if current module is a package, i.e. an __init__ file.
Class Variable default_deprecated_modules Undocumented
Class Variable msgs Undocumented
Class Variable name Name of the provider.
Class Variable options Options provided by this provider.
Instance Variable import_graph Undocumented
Instance Variable preferred_modules Undocumented
Instance Variable reports Undocumented
Static Method _is_fallback_import Undocumented
Method _add_imported_module Notify an imported module, used to analyze dependencies.
Method _check_import_as_rename Undocumented
Method _check_imports_order Checks imports of module `node` are grouped by category.
Method _check_misplaced_future Undocumented
Method _check_position Check `node` import or importfrom node position is correct.
Method _check_preferred_module Check if the module has a preferred replacement.
Method _check_reimport Check if a module with the same name is already imported or aliased.
Method _check_same_line_imports Undocumented
Method _check_toplevel Check whether the import is made outside the module toplevel.
Method _check_wildcard_imports Undocumented
Method _external_dependencies_info Return cached external dependencies information or build and cache them.
Method _filter_dependencies_graph Build the internal or the external dependency graph.
Method _get_imported_module Undocumented
Method _import_graph_without_ignored_edges Undocumented
Method _internal_dependencies_info Return cached internal dependencies information or build and cache them.
Method _record_import Record the package `node` imports from.
Method _report_dependencies_graph Write dependencies as a dot (graphviz) file.
Method _report_external_dependencies Return a verbatim layout for displaying dependencies.
Method _wildcard_import_is_allowed Undocumented
Instance Variable _allow_any_import_level Undocumented
Instance Variable _allow_reexport_package Undocumented
Instance Variable _current_module_package Undocumented
Instance Variable _excluded_edges Undocumented
Instance Variable _first_non_import_node Undocumented
Instance Variable _ignored_modules Undocumented
Instance Variable _imports_stack Undocumented
Instance Variable _module_pkg Undocumented

Inherited from DeprecatedMixin:

Method check_deprecated_class Checks if the class is deprecated.
Method check_deprecated_class_in_call Checks if call the deprecated class.
Method check_deprecated_method Executes the checker for the given node.
Method check_deprecated_module Checks if the module is deprecated.
Method deprecated_arguments Callback returning the deprecated arguments of method/function.
Method deprecated_classes Callback returning the deprecated classes of module.
Method deprecated_decorators Callback returning the deprecated decorators.
Method deprecated_methods Callback returning the deprecated methods/functions.
Method visit_call Called when a :class:`nodes.Call` node is visited.
Method visit_decorators Triggered when a decorator statement is seen.
Constant DEPRECATED_ARGUMENT_MESSAGE Undocumented
Constant DEPRECATED_CLASS_MESSAGE Undocumented
Constant DEPRECATED_DECORATOR_MESSAGE Undocumented
Constant DEPRECATED_METHOD_MESSAGE Undocumented
Constant DEPRECATED_MODULE_MESSAGE Undocumented

Inherited from BaseChecker (via DeprecatedMixin):

Method __eq__ Permit to assert Checkers are equal.
Method __gt__ Sorting of checkers.
Method __hash__ Make Checker hashable.
Method __repr__ Undocumented
Method __str__ This might be incomplete because multiple classes inheriting BaseChecker can have the same name.
Method add_message Undocumented
Method check_consistency Check the consistency of msgid.
Method create_message_definition_from_tuple Undocumented
Method get_full_documentation Undocumented
Method get_map_data Undocumented
Method get_message_definition Undocumented
Method reduce_map_data Undocumented
Class Variable enabled Undocumented
Instance Variable linter Undocumented
Property messages Undocumented

Inherited from _ArgumentsProvider (via DeprecatedMixin, BaseChecker):

Method get_option_def DEPRECATED: Return the dictionary defining an option given its name.
Method level.setter Undocumented
Method load_defaults DEPRECATED: Initialize the provider using default values.
Method option_attrname DEPRECATED: Get the config attribute corresponding to opt.
Method option_value DEPRECATED: Get the current value for the given option.
Method options_and_values DEPRECATED.
Method options_by_section DEPRECATED: Return an iterator on options grouped by section.
Method set_option DEPRECATED: Method called to set an option (registered in the options list).
Class Variable option_groups_descs Option groups of this provider and their descriptions.
Property config Undocumented
Property level Undocumented
Instance Variable _arguments_manager The manager that will parse and register any options provided.
Instance Variable _level Undocumented
def __init__(self, linter: PyLinter): (source)

Checker instances should have the linter as argument.

def close(self): (source)

Called before visiting project (i.e set of modules).

def deprecated_modules(self) -> set[str]: (source)

Callback returning the deprecated modules.

def leave_module(self, node: nodes.Module): (source)

Undocumented

def open(self): (source)

Called before visiting project (i.e set of modules).

def visit_functiondef(self, node: ((nodes.FunctionDef|nodes.While)|nodes.For)|nodes.ClassDef): (source)

Undocumented

def visit_import(self, node: nodes.Import): (source)

Triggered when an import statement is seen.

def visit_importfrom(self, node: nodes.ImportFrom): (source)

Triggered when a from statement is seen.

def visit_module(self, node: nodes.Module): (source)

Store if current module is a package, i.e. an __init__ file.

default_deprecated_modules: tuple = (source)

Undocumented

Name of the provider.

Options provided by this provider.

import_graph = (source)

Undocumented

preferred_modules = (source)

Undocumented

@staticmethod
def _is_fallback_import(node: ImportNode, imports: list[tuple[ImportNode, str]]) -> bool: (source)

Undocumented

def _add_imported_module(self, node: ImportNode, importedmodname: str): (source)

Notify an imported module, used to analyze dependencies.

def _check_import_as_rename(self, node: ImportNode): (source)

Undocumented

def _check_imports_order(self, _module_node: nodes.Module) -> tuple[list[tuple[ImportNode, str]], list[tuple[ImportNode, str]], list[tuple[ImportNode, str]]]: (source)

Checks imports of module `node` are grouped by category. Imports must follow this order: standard, 3rd party, local

def _check_misplaced_future(self, node: nodes.ImportFrom): (source)

Undocumented

def _check_position(self, node: ImportNode): (source)

Check `node` import or importfrom node position is correct. Send a message if `node` comes before another instruction

def _check_preferred_module(self, node: ImportNode, mod_path: str): (source)

Check if the module has a preferred replacement.

def _check_reimport(self, node: ImportNode, basename: str|None = None, level: int|None = None): (source)

Check if a module with the same name is already imported or aliased.

def _check_same_line_imports(self, node: nodes.ImportFrom): (source)

Undocumented

def _check_toplevel(self, node: ImportNode): (source)

Check whether the import is made outside the module toplevel.

def _check_wildcard_imports(self, node: nodes.ImportFrom, imported_module: nodes.Module|None): (source)

Undocumented

@astroid.decorators.cached
def _external_dependencies_info(self) -> defaultdict[str, set[str]]: (source)

Return cached external dependencies information or build and cache them.

def _filter_dependencies_graph(self, internal: bool) -> defaultdict[str, set[str]]: (source)

Build the internal or the external dependency graph.

def _get_imported_module(self, importnode: ImportNode, modname: str|None) -> nodes.Module|None: (source)

Undocumented

def _import_graph_without_ignored_edges(self) -> defaultdict[str, set[str]]: (source)

Undocumented

@astroid.decorators.cached
def _internal_dependencies_info(self) -> defaultdict[str, set[str]]: (source)

Return cached internal dependencies information or build and cache them.

def _record_import(self, node: ImportNode, importedmodnode: nodes.Module|None): (source)

Record the package `node` imports from.

def _report_dependencies_graph(self, sect: Section, _: LinterStats, _dummy: LinterStats|None): (source)

Write dependencies as a dot (graphviz) file.

def _report_external_dependencies(self, sect: Section, _: LinterStats, _dummy: LinterStats|None): (source)

Return a verbatim layout for displaying dependencies.

def _wildcard_import_is_allowed(self, imported_module: nodes.Module|None) -> bool: (source)

Undocumented

_allow_any_import_level = (source)

Undocumented

_allow_reexport_package = (source)

Undocumented

_current_module_package = (source)

Undocumented

_excluded_edges: defaultdict[str, set[str]] = (source)

Undocumented

_first_non_import_node = (source)

Undocumented

_ignored_modules: Sequence[str] = (source)

Undocumented

_imports_stack: list = (source)

Undocumented

_module_pkg: dict = (source)

Undocumented