Skip to content

Commit

Permalink
Fix list sub-type type resolution (#141)
Browse files Browse the repository at this point in the history
* Fix list sub-type type resolution

* Wrap line

* Added input for field in test

* Fix line length
  • Loading branch information
jaredoconnell authored Nov 8, 2024
1 parent 6dcecbd commit d4b7c9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/arcaflow_plugin_sdk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion src/arcaflow_plugin_sdk/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,18 @@ 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),
TestData1(
A="Hello world!",
B=5,
C={},
D=[],
H=3.14,
J=[{"a": "b"}],
),
self.fail,
)

Expand Down

0 comments on commit d4b7c9f

Please sign in to comment.