From 5d0f2da0ff8953e20548989f151fb49056b79237 Mon Sep 17 00:00:00 2001 From: Jared O'Connell Date: Fri, 8 Nov 2024 11:03:12 -0500 Subject: [PATCH 1/4] Fix list sub-type type resolution --- src/arcaflow_plugin_sdk/schema.py | 4 +++- src/arcaflow_plugin_sdk/test_schema.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arcaflow_plugin_sdk/schema.py b/src/arcaflow_plugin_sdk/schema.py index dccd878..3e25b5e 100644 --- a/src/arcaflow_plugin_sdk/schema.py +++ b/src/arcaflow_plugin_sdk/schema.py @@ -6787,12 +6787,14 @@ def _resolve_list_annotation( "List type without item type definition encountered, please" " declare your lists like this: typing.List[str]", ) + sub_type = args[0] + new_path = list(path) new_path.append("items") try: return ListType( cls._resolve_abstract_type( - args[0], type_hints, tuple(new_path), scope + sub_type, sub_type, tuple(new_path), scope ) ) except Exception as e: diff --git a/src/arcaflow_plugin_sdk/test_schema.py b/src/arcaflow_plugin_sdk/test_schema.py index 8d77019..7bc53a3 100644 --- a/src/arcaflow_plugin_sdk/test_schema.py +++ b/src/arcaflow_plugin_sdk/test_schema.py @@ -963,6 +963,7 @@ class TestData1: default="", metadata={"id": "test-field", "name": "G"} ) I: typing.Any = None + J: typing.List[typing.Dict[str, str]] = dataclasses.field(default_factory=list) schema.test_object_serialization( TestData1(A="Hello world!", B=5, C={}, D=[], H=3.14), From 1c1fb0f0e4be76799980b9e8abdda617313e5321 Mon Sep 17 00:00:00 2001 From: Jared O'Connell Date: Fri, 8 Nov 2024 11:06:09 -0500 Subject: [PATCH 2/4] Wrap line --- src/arcaflow_plugin_sdk/test_schema.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arcaflow_plugin_sdk/test_schema.py b/src/arcaflow_plugin_sdk/test_schema.py index 7bc53a3..f9488d6 100644 --- a/src/arcaflow_plugin_sdk/test_schema.py +++ b/src/arcaflow_plugin_sdk/test_schema.py @@ -963,7 +963,8 @@ class TestData1: default="", metadata={"id": "test-field", "name": "G"} ) I: typing.Any = None - J: typing.List[typing.Dict[str, str]] = dataclasses.field(default_factory=list) + J: typing.List[typing.Dict[str, str]] \ + = dataclasses.field(default_factory=list) schema.test_object_serialization( TestData1(A="Hello world!", B=5, C={}, D=[], H=3.14), From 744505d8caab7cc5397f32ed67a1bbbbc1c68836 Mon Sep 17 00:00:00 2001 From: Jared O'Connell Date: Fri, 8 Nov 2024 11:36:45 -0500 Subject: [PATCH 3/4] Added input for field in test --- src/arcaflow_plugin_sdk/test_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arcaflow_plugin_sdk/test_schema.py b/src/arcaflow_plugin_sdk/test_schema.py index f9488d6..a20947b 100644 --- a/src/arcaflow_plugin_sdk/test_schema.py +++ b/src/arcaflow_plugin_sdk/test_schema.py @@ -967,7 +967,7 @@ class TestData1: = dataclasses.field(default_factory=list) schema.test_object_serialization( - TestData1(A="Hello world!", B=5, C={}, D=[], H=3.14), + TestData1(A="Hello world!", B=5, C={}, D=[], H=3.14, J=[{"a": "b"}]), self.fail, ) From 9bd8645b6ad769d9590f6c54e71b97a518f019ab Mon Sep 17 00:00:00 2001 From: Jared O'Connell Date: Fri, 8 Nov 2024 11:39:12 -0500 Subject: [PATCH 4/4] Fix line length --- src/arcaflow_plugin_sdk/test_schema.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/arcaflow_plugin_sdk/test_schema.py b/src/arcaflow_plugin_sdk/test_schema.py index a20947b..b5e671e 100644 --- a/src/arcaflow_plugin_sdk/test_schema.py +++ b/src/arcaflow_plugin_sdk/test_schema.py @@ -967,7 +967,14 @@ class TestData1: = dataclasses.field(default_factory=list) schema.test_object_serialization( - TestData1(A="Hello world!", B=5, C={}, D=[], H=3.14, J=[{"a": "b"}]), + TestData1( + A="Hello world!", + B=5, + C={}, + D=[], + H=3.14, + J=[{"a": "b"}], + ), self.fail, )