From 95fc4cf322b2141f76142e46e96e2846f5034edf Mon Sep 17 00:00:00 2001 From: Janine vN Date: Tue, 22 Jul 2025 15:43:02 -0400 Subject: [PATCH 1/2] Add dynamic module loading fix for dataclasses --- resources/unittest_template.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/unittest_template.py b/resources/unittest_template.py index d1944ee..5cdb8ec 100644 --- a/resources/unittest_template.py +++ b/resources/unittest_template.py @@ -52,6 +52,12 @@ def _load_user_module(result_writer, exit_wrapper: _EXIT_WRAPPER_TYPE) -> Module exit_wrapper(5) _module = ModuleType("module") + # It's necessary to manually add the module to the sys modules + # Dataclasses do not add themselves which causes issues for us with this type of dynamic loading + # if from __future__ import annotations is also used + # See: https://github.com/mkdocs/mkdocs/issues/3141 and https://github.com/sqlalchemy/alembic/issues/1419 + sys.modules[_module.__name__] = _module + exec(code, _module.__dict__) return _module From 111c06399d3477f3680320307547eb85891b055b Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Tue, 22 Jul 2025 20:54:44 +0100 Subject: [PATCH 2/2] KUTIEKAT ALWAYS LINTS BEFORE PUSHING --- resources/unittest_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/unittest_template.py b/resources/unittest_template.py index 5cdb8ec..28dd588 100644 --- a/resources/unittest_template.py +++ b/resources/unittest_template.py @@ -57,7 +57,7 @@ def _load_user_module(result_writer, exit_wrapper: _EXIT_WRAPPER_TYPE) -> Module # if from __future__ import annotations is also used # See: https://github.com/mkdocs/mkdocs/issues/3141 and https://github.com/sqlalchemy/alembic/issues/1419 sys.modules[_module.__name__] = _module - + exec(code, _module.__dict__) return _module