diff --git a/bigraph_schema/data.py b/bigraph_schema/data.py deleted file mode 100644 index 8b13789..0000000 --- a/bigraph_schema/data.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bigraph_schema/type_functions.py b/bigraph_schema/type_functions.py index 90d439c..ff406c4 100644 --- a/bigraph_schema/type_functions.py +++ b/bigraph_schema/type_functions.py @@ -63,6 +63,8 @@ """ +import sys +import types import copy import numbers import numpy as np @@ -81,9 +83,14 @@ deep_merge, hierarchy_depth, establish_path) -import bigraph_schema.data as data -import bigraph_schema.data +# Create a new module dynamically for the dataclasses +module_name = 'bigraph_schema.data' +if module_name not in sys.modules: + data_module = types.ModuleType(module_name) + sys.modules[module_name] = data_module +else: + data_module = sys.modules[module_name] overridable_schema_keys = set([ '_type', @@ -1760,7 +1767,7 @@ def default(subschema=subschema): '__module__': 'bigraph_schema.data'}) setattr( - bigraph_schema.data, + data_module, dataclass_name, dataclass) @@ -1837,7 +1844,7 @@ def dataclass_tree(schema, path, core): 'Optional': Optional, 'str': str }) - setattr(data, dataclass_name, dataclass) + setattr(data_module, dataclass_name, dataclass) return dataclass diff --git a/bigraph_schema/type_system_tests.py b/bigraph_schema/type_system_tests.py index a5d3c87..fcfe6c4 100644 --- a/bigraph_schema/type_system_tests.py +++ b/bigraph_schema/type_system_tests.py @@ -8,12 +8,11 @@ from dataclasses import asdict from bigraph_schema.type_functions import ( - divide_longest, base_type_library, accumulate, to_string, deserialize_integer, apply_schema, diff + divide_longest, base_type_library, accumulate, to_string, deserialize_integer, apply_schema, diff, data_module ) from bigraph_schema import TypeSystem from bigraph_schema.units import units from bigraph_schema.registry import establish_path, remove_omitted, NONE_SYMBOL -import bigraph_schema.data as data @pytest.fixture @@ -1965,9 +1964,9 @@ def test_dataclass(core): 'b': 888.88}, 'x': 111.11111}} - nested_new = data.nested( - data.nested_a( - data.nested_a_a( + nested_new = data_module.nested( + data_module.nested_a( + data_module.nested_a_a( a=222.22, b=3.3333), 5555.55))