Skip to content

Commit

Permalink
Handle AST.expr in static object analysis
Browse files Browse the repository at this point in the history
The ast module in Python 3.9 has some API changes. Quoting [1]:

    Simplified AST for subscription. Simple indices will be represented
    by their value, extended slices will be represented as tuples.
    Index(value) will return a value itself, ExtSlice(slices) will
    return Tuple(slices, Load()). (Contributed by Serhiy Storchaka in
    bpo-34822.)

[1] https://docs.python.org/3/whatsnew/3.9.html#changes-in-the-python-api

This fixes the remaining 4 failures under Python 3.9.

FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_append_function
FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_for_loops
FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_dicts_depending_on_update
FAILED ropetest/advanced_oi_test.py::NewStaticOITest::test_static_oi_for_lists_per_object_for_set_item

Fixes: #299
  • Loading branch information
mattst88 committed Mar 19, 2021
1 parent 02284e4 commit 46a3403
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rope/base/oi/soa.py
Expand Up @@ -126,7 +126,7 @@ def _evaluate_assign_value(self, node, nodes, type_hint=False):
for subscript, levels in nodes:
instance = evaluate.eval_node(self.scope, subscript.value)
args_pynames = [evaluate.eval_node(self.scope,
subscript.slice.value)]
subscript.slice)]
value = rope.base.oi.soi._infer_assignment(
rope.base.pynames.AssignmentValue(node.value, levels,
type_hint=type_hint),
Expand All @@ -149,5 +149,5 @@ def __init__(self):

def _added(self, node, levels):
if isinstance(node, rope.base.ast.Subscript) and \
isinstance(node.slice, rope.base.ast.Index):
isinstance(node.slice, (rope.base.ast.Index, rope.base.ast.expr)):
self.nodes.append((node, levels))

0 comments on commit 46a3403

Please sign in to comment.