summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-08 01:07:09 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-08 01:07:09 +0300
commitb6455a5aeb20e868c24094d6f6b9962bb52f8127 (patch)
tree23e5be3480c4843ef1ddec2d7e97ee2c42ffecb6
parentb86e69cdf08cbde1696745ce31c2358bd564d845 (diff)
downloadastroid-b6455a5aeb20e868c24094d6f6b9962bb52f8127.tar.gz
Make duplicated_kwargs a public API.
-rw-r--r--astroid/arguments.py7
-rw-r--r--astroid/tests/unittest_inference.py5
2 files changed, 8 insertions, 4 deletions
diff --git a/astroid/arguments.py b/astroid/arguments.py
index bdce172..5670fa8 100644
--- a/astroid/arguments.py
+++ b/astroid/arguments.py
@@ -38,8 +38,7 @@ class CallSite(object):
def __init__(self, callcontext):
args = callcontext.args
keywords = callcontext.keywords
-
- self._duplicated_kwargs = {}
+ self.duplicated_keywords = set()
self._unpacked_args = self._unpack_args(args)
self._unpacked_kwargs = self._unpack_keywords(keywords)
@@ -111,7 +110,7 @@ class CallSite(object):
if dict_key.value in values:
# The name is already in the dictionary
values[dict_key.value] = util.YES
- self._duplicated_kwargs[dict_key.value] = True
+ self.duplicated_keywords.add(dict_key.value)
continue
values[dict_key.value] = dict_value
else:
@@ -143,7 +142,7 @@ class CallSite(object):
def infer_argument(self, funcnode, name, context):
"""infer a function argument value according to the call context"""
- if name in self._duplicated_kwargs:
+ if name in self.duplicated_keywords:
raise exceptions.InferenceError(name)
# Look into the keywords first, maybe it's already there.
diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py
index 5fac5f9..ed13fc2 100644
--- a/astroid/tests/unittest_inference.py
+++ b/astroid/tests/unittest_inference.py
@@ -3766,6 +3766,11 @@ class CallSiteTest(unittest.TestCase):
]
self._test_call_site_valid_arguments(values, invalid=False)
+ def test_duplicated_keyword_arguments(self):
+ ast_node = test_utils.extract_node('f(f=24, **{"f": 25})')
+ site = self._call_site_from_call(ast_node)
+ self.assertIn('f', site.duplicated_keywords)
+
if __name__ == '__main__':
unittest.main()