From 9b8526f5778259bb2032d690bd920af1f7c7be3e Mon Sep 17 00:00:00 2001 From: Craig Barratt <19445341+craigbarratt@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:06:44 -0800 Subject: [PATCH] fixes #683 --- custom_components/pyscript/eval.py | 2 +- tests/test_unit_eval.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/custom_components/pyscript/eval.py b/custom_components/pyscript/eval.py index 958dce0..39ac56d 100644 --- a/custom_components/pyscript/eval.py +++ b/custom_components/pyscript/eval.py @@ -2047,7 +2047,7 @@ async def get_names_set(self, arg, names, nonlocal_names, global_names, local_na cls_name = arg.__class__.__name__ if cls_name == "Attribute": - full_name = await self.ast_attribute_collapse(arg) + full_name = await self.ast_attribute_collapse(arg, check_undef=False) if full_name is not None: names.add(full_name) return diff --git a/tests/test_unit_eval.py b/tests/test_unit_eval.py index c3f55a5..7deb97f 100644 --- a/tests/test_unit_eval.py +++ b/tests/test_unit_eval.py @@ -1390,6 +1390,22 @@ def func(arg): """, [0, 1, True, True, True], ], + [ + """ +def foo(): + def bar(): + result = [] + result.append("bar") + other = 1 + return result + + result = bar() + return result + +foo() +""", + ["bar"], + ], ]