From b5964519ac4e4a33a1b68567a149ed7fc7674521 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Wed, 27 Feb 2019 11:02:15 +0100 Subject: 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. --- pylint/checkers/typecheck.py | 8 +++++--- 1 file 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): -- cgit v1.2.1