diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-10 11:22:45 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-10-10 11:22:45 +0200 |
commit | fe9324c87e285fda1f0195d91fa8bdbde210b2f2 (patch) | |
tree | d5ae68d36603688b027b2da10cdac38d5067bc29 /astroid/context.py | |
parent | 3d58a62cefa30fdd20ab303227f6dd6f2bd60830 (diff) | |
download | astroid-git-fe9324c87e285fda1f0195d91fa8bdbde210b2f2.tar.gz |
Use copy_context where it makes sense
Diffstat (limited to 'astroid/context.py')
-rw-r--r-- | astroid/context.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/astroid/context.py b/astroid/context.py index 1d6dab5c..dcdd559c 100644 --- a/astroid/context.py +++ b/astroid/context.py @@ -11,6 +11,7 @@ import contextlib import copy import pprint +from typing import Optional class InferenceContext: @@ -150,7 +151,8 @@ class CallContext: self.keywords = keywords -def copy_context(context): +def copy_context(context: Optional[InferenceContext]) -> InferenceContext: + """Clone a context if given, or return a fresh contexxt""" if context is not None: return context.clone() @@ -174,9 +176,6 @@ def bind_context_to_node(context, node): :returns: A new context :rtype: InferenceContext """ - if context is not None: - context = context.clone() - else: - context = InferenceContext() + context = copy_context(context) context.boundnode = node return context |