diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2019-04-09 17:00:47 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-04-09 17:00:47 +0200 |
commit | e0a298df55b15abcb77c2a93253f5ab7be52d0fb (patch) | |
tree | 8c9b3604f0aabbdbd766ff3d3d1304219d225ad8 /astroid/protocols.py | |
parent | 55076ca06018dd3a5d2748610c5aa81efbb96563 (diff) | |
download | astroid-git-e0a298df55b15abcb77c2a93253f5ab7be52d0fb.tar.gz |
Drop a superfluous and wrong callcontext when inferring the result of a context manager
The callcontext was containing the instance of the class (self) as the sole argument,
but this was tripping the inference of unknown arguments coming down into an
instance, such as the one from the commit's example.
By dropping the superfluous callcontext, the inference can no longer assume
that the first argument is the instance of the class, leading to wrongly
infer `self.client` as the first argument of the instantiation call.
Close PyCQA/pylint#2859
Diffstat (limited to 'astroid/protocols.py')
-rw-r--r-- | astroid/protocols.py | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/astroid/protocols.py b/astroid/protocols.py index db0f5d9d..bf497ff1 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -494,8 +494,6 @@ def _infer_context_manager(self, mgr, context): raise exceptions.InferenceError(node=inferred) if not isinstance(enter, bases.BoundMethod): raise exceptions.InferenceError(node=enter) - if not context.callcontext: - context.callcontext = contextmod.CallContext(args=[inferred]) yield from enter.infer_call_result(self, context) else: raise exceptions.InferenceError(node=mgr) |