summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-02-27 11:02:15 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2019-02-27 11:02:15 +0100
commitb5964519ac4e4a33a1b68567a149ed7fc7674521 (patch)
treef6bcde031024f587a261ac9085c291f08255d1a9
parenteef175ea483be822d9b7ec7cb4c5d89004904e96 (diff)
downloadpylint-git-b5964519ac4e4a33a1b68567a149ed7fc7674521.tar.gz
Use safe_infer() when inferring context's paths to prevent the acceptance tests to fail for distutils
Currently this check fails for distutils because one of the `path` objects is an `ImportFrom` that raises an `InferenceError` when trying to be inferred.
-rw-r--r--pylint/checkers/typecheck.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 8f26e0b4f..417662b87 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -1395,10 +1395,12 @@ accessed. Python regular expressions are accepted.",
# Retrieve node from all previusly visited nodes in the the inference history
context_path_names = filter(None, _unflatten(context.path))
inferred_paths = _flatten_container(
- path.infer() for path in context_path_names
+ safe_infer(path) for path in context_path_names
)
- for inf_path in inferred_paths:
- scope = inf_path.scope()
+ for inferred_path in inferred_paths:
+ if not inferred_path:
+ continue
+ scope = inferred_path.scope()
if not isinstance(scope, astroid.FunctionDef):
continue
if decorated_with(scope, self.config.contextmanager_decorators):