diff --git a/precli/parsers/python.py b/precli/parsers/python.py index c0f97744..c3a58f25 100644 --- a/precli/parsers/python.py +++ b/precli/parsers/python.py @@ -131,7 +131,7 @@ def visit_assignment(self, nodes: list[Node]): nodes[2].children[1] ) - if self.context["node"].children: + if nodes[2].children: # (attribute | identifier) argument_list func_node = nodes[2].children[0] var_node = self._get_var_node(func_node) diff --git a/tests/unit/parsers/examples/expression_list_assignment.py b/tests/unit/parsers/examples/expression_list_assignment.py index f75f22ed..1933a07b 100644 --- a/tests/unit/parsers/examples/expression_list_assignment.py +++ b/tests/unit/parsers/examples/expression_list_assignment.py @@ -1,6 +1,4 @@ -import torch +import ssl -torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) -x = torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) -b, *_, device = *x.shape, x.device +ssl_ctx1, ssl_ctx2 = ssl.SSLContext(), ssl.SSLContext() diff --git a/tests/unit/parsers/examples/expression_list_assignment_uneven.py b/tests/unit/parsers/examples/expression_list_assignment_uneven.py new file mode 100644 index 00000000..f75f22ed --- /dev/null +++ b/tests/unit/parsers/examples/expression_list_assignment_uneven.py @@ -0,0 +1,6 @@ +import torch + + +torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) +x = torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]]) +b, *_, device = *x.shape, x.device diff --git a/tests/unit/parsers/test_python.py b/tests/unit/parsers/test_python.py index 8003324c..9a89ea36 100644 --- a/tests/unit/parsers/test_python.py +++ b/tests/unit/parsers/test_python.py @@ -26,6 +26,15 @@ def test_expression_list_assignment(self): results = self.parser.parse(artifact) self.assertEqual(0, len(results)) + def test_expression_list_assignment_uneven(self): + artifact = Artifact( + os.path.join( + self.base_path, "expression_list_assignment_uneven.py" + ) + ) + results = self.parser.parse(artifact) + self.assertEqual(0, len(results)) + def test_importlib_import_module(self): artifact = Artifact( os.path.join(self.base_path, "importlib_import_module.py")