Skip to content

Commit

Permalink
Rename import exemption option to be different than the check name
Browse files Browse the repository at this point in the history
  • Loading branch information
PCManticore committed Sep 17, 2019
1 parent ee3e16c commit e457c45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,15 @@ class ImportsChecker(BaseChecker):
},
),
(
"import-outside-toplevel",
"allow-any-import-level",
{
"default": (),
"type": "csv",
"metavar": "<modules>",
"help": "Modules that can be imported outside the toplevel "
"of other modules.",
"help": (
"List of modules that can be imported at any level, not just "
"the top level one."
),
},
),
(
Expand Down Expand Up @@ -415,7 +417,7 @@ def __init__(self, linter=None):
self._imports_stack = []
self._first_non_import_node = None
self._module_pkg = {} # mapping of modules to the pkg they belong in
self._import_outside_toplevel = set()
self._allow_any_import_level = set()
self.reports = (
("RP0401", "External dependencies", self._report_external_dependencies),
("RP0402", "Modules dependencies graph", self._report_dependencies_graph),
Expand Down Expand Up @@ -463,7 +465,7 @@ def open(self):
for module in self.config.preferred_modules
if ":" in module
)
self._import_outside_toplevel = set(self.config.import_outside_toplevel)
self._allow_any_import_level = set(self.config.allow_any_import_level)

def _import_graph_without_ignored_edges(self):
filtered_graph = copy.deepcopy(self.import_graph)
Expand Down Expand Up @@ -965,7 +967,7 @@ def _check_toplevel(self, node):

# Get the full names of all the imports that are not whitelisted.
scoped_imports = [
name for name in module_names if name not in self._import_outside_toplevel
name for name in module_names if name not in self._allow_any_import_level
]

if scoped_imports:
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_checker_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestImportsChecker(CheckerTestCase):

CHECKER_CLASS = imports.ImportsChecker

@set_config(import_outside_toplevel=("astroid",))
@set_config(allow_any_import_level=("astroid",))
def test_import_outside_toplevel(self):
node = astroid.extract_node(
"""
Expand Down

0 comments on commit e457c45

Please sign in to comment.