Fix usages in context of the new parso parameter include_setitem=True

This commit is contained in:
Dave Halter
2019-08-28 22:56:16 +02:00
parent 7d28f4ce5b
commit 4572503c9f
5 changed files with 5 additions and 6 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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':

View File

@@ -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':

View File

@@ -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