diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2019-01-15 14:28:06 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-01-15 14:28:06 +0100 |
| commit | e4293491ef92fec3f820241559951c97ca0db302 (patch) | |
| tree | 1d68015efbc3f9622e297bb6d18b724dfceb85b2 | |
| parent | 654dd1d3ca5190cce0988c806ec07f854344e2b4 (diff) | |
| download | astroid-git-e4293491ef92fec3f820241559951c97ca0db302.tar.gz | |
Pass a context in the places where we don't do that explicitly
| -rw-r--r-- | astroid/arguments.py | 2 | ||||
| -rw-r--r-- | astroid/helpers.py | 2 | ||||
| -rw-r--r-- | astroid/inference.py | 5 | ||||
| -rw-r--r-- | astroid/scoped_nodes.py | 2 |
4 files changed, 7 insertions, 4 deletions
diff --git a/astroid/arguments.py b/astroid/arguments.py index 6a8952e8..60348c07 100644 --- a/astroid/arguments.py +++ b/astroid/arguments.py @@ -204,7 +204,7 @@ class CallSite: # `cls.metaclass_method`. In this case, the # first argument is always the class. method_scope = funcnode.parent.scope() - if method_scope is boundnode.metaclass(): + if method_scope is boundnode.metaclass(context=context): return iter((boundnode,)) if funcnode.type == "method": diff --git a/astroid/helpers.py b/astroid/helpers.py index 94019131..4bed9725 100644 --- a/astroid/helpers.py +++ b/astroid/helpers.py @@ -52,7 +52,7 @@ def _object_type(node, context=contextmod.global_context): for inferred in node.infer(context=context): if isinstance(inferred, scoped_nodes.ClassDef): if inferred.newstyle: - metaclass = inferred.metaclass() + metaclass = inferred.metaclass(context=context) if metaclass: yield metaclass continue diff --git a/astroid/inference.py b/astroid/inference.py index 0d7358d5..157a053d 100644 --- a/astroid/inference.py +++ b/astroid/inference.py @@ -251,6 +251,7 @@ nodes.Import._infer = infer_import @decorators.path_wrapper def infer_import_from(self, context=contextmod.global_context, asname=True): """infer a ImportFrom node: return the imported module/object""" + context = context or contextmod.global_context name = context.lookupname if name is None: raise exceptions.InferenceError(node=self, context=context) @@ -265,7 +266,9 @@ def infer_import_from(self, context=contextmod.global_context, asname=True): try: context = contextmod.copy_context(context, branch_path=False) context.lookupname = name - stmts = module.getattr(name, ignore_locals=module is self.root()) + stmts = module.getattr( + name, ignore_locals=module is self.root(), context=context + ) return bases._infer_stmts(stmts, context) except exceptions.AttributeInferenceError as error: raise exceptions.InferenceError( diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index 4f46f328..36f65a0e 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -2374,7 +2374,7 @@ class ClassDef(mixins.FilterStmtsMixin, LocalsDictNodeNG, node_classes.Statement """Search the given name in the implicit and the explicit metaclass.""" attrs = set() implicit_meta = self.implicit_metaclass() - metaclass = self.metaclass() + metaclass = self.metaclass(context=context) for cls in {implicit_meta, metaclass}: if cls and cls != self and isinstance(cls, ClassDef): cls_attributes = self._get_attribute_from_metaclass(cls, name, context) |
