From 4572503c9f014b1845a236fa4fef36da5fffb633 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 28 Aug 2019 22:56:16 +0200 Subject: [PATCH] Fix usages in context of the new parso parameter include_setitem=True --- jedi/api/classes.py | 2 +- jedi/inference/filters.py | 2 +- jedi/inference/syntax_tree.py | 4 ++-- jedi/inference/value/klass.py | 2 +- test/completion/dynamic_arrays.py | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 5a889d37..580e6d7b 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -553,7 +553,7 @@ class Definition(BaseDefinition): typ = 'def' return typ + ' ' + self._name.get_public_name() - definition = tree_name.get_definition() or tree_name + definition = tree_name.get_definition(include_setitem=True) or tree_name # Remove the prefix, because that's not what we want for get_code # here. txt = definition.get_code(include_prefix=False) diff --git a/jedi/inference/filters.py b/jedi/inference/filters.py index 4418ceaf..4ce6bff2 100644 --- a/jedi/inference/filters.py +++ b/jedi/inference/filters.py @@ -62,7 +62,7 @@ def _get_definition_names(used_names, name_key): except KeyError: names = used_names.get(name_key, ()) result = for_module[name_key] = tuple( - name for name in names if name.is_definition() + name for name in names if name.is_definition(include_setitem=True) ) return result diff --git a/jedi/inference/syntax_tree.py b/jedi/inference/syntax_tree.py index 86eb0d47..52bf582b 100644 --- a/jedi/inference/syntax_tree.py +++ b/jedi/inference/syntax_tree.py @@ -323,7 +323,7 @@ def _infer_expr_stmt(context, stmt, seek_name=None): is_annassign = first_operator not in ('=', None) and first_operator.type == 'operator' if is_annassign or is_setitem: # `=` is always the last character in aug assignments -> -1 - name = stmt.get_defined_names()[0].value + name = stmt.get_defined_names(include_setitem=True)[0].value left_values = context.py__getattribute__(name, position=stmt.start_pos) if is_setitem: @@ -594,7 +594,7 @@ def tree_name_to_values(inference_state, context, tree_name): return value_set types = [] - node = tree_name.get_definition(import_name_always=True) + node = tree_name.get_definition(import_name_always=True, include_setitem=True) if node is None: node = tree_name.parent if node.type == 'global_stmt': diff --git a/jedi/inference/value/klass.py b/jedi/inference/value/klass.py index 9dc0911f..3ab4c57e 100644 --- a/jedi/inference/value/klass.py +++ b/jedi/inference/value/klass.py @@ -120,7 +120,7 @@ class ClassFilter(ParserTreeFilter): # Filter for ClassVar variables # TODO this is not properly done, yet. It just checks for the string # ClassVar in the annotation, which can be quite imprecise. If we - # wanted to do this correct, we would have to resolve the ClassVar. + # wanted to do this correct, we would have to infer the ClassVar. if not from_instance: expr_stmt = name.get_definition() if expr_stmt is not None and expr_stmt.type == 'expr_stmt': diff --git a/test/completion/dynamic_arrays.py b/test/completion/dynamic_arrays.py index 8c68de0c..544d30ec 100644 --- a/test/completion/dynamic_arrays.py +++ b/test/completion/dynamic_arrays.py @@ -368,7 +368,6 @@ some_dct['unknown'] some_dct['a'] some_dct = dict({'a': 1, 1: ''}) -some_dct = dict(a=1, x=''}) #? int() str() some_dct['la'] some_dct['x'] = list