From cf2e98cb75c75dc3e566ed0205637dbd4632e159 Mon Sep 17 00:00:00 2001 From: Ritvik Nag Date: Sat, 9 Nov 2024 14:33:25 -0500 Subject: [PATCH] Add test case to satisfy #89 --- tests/unit/test_load.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/test_load.py b/tests/unit/test_load.py index 9703fd5b..cea042df 100644 --- a/tests/unit/test_load.py +++ b/tests/unit/test_load.py @@ -1801,3 +1801,30 @@ class Outer(JSONWizard): # the error should mention that we want a dict, but get a list assert e.ann_type == dict assert e.obj_type == list + + +def test_load_with_python_3_11_regression(): + """ + This test case is to confirm intended operation with `typing.Any` + (either explicit or implicit in plain `list` or `dict` type + annotations). + + Note: I have been unable to reproduce [the issue] posted on GitHub. + I've tested this on multiple Python versions on Mac, including + 3.10.6, 3.11.0, 3.11.5, 3.11.10. + + See [the issue]. + + [the issue]: https://github.com/rnag/dataclass-wizard/issues/89 + """ + + @dataclass + class Item(JSONSerializable): + a: dict + b: Optional[dict] + c: Optional[list] = None + + item = Item.from_json('{"a": {}, "b": null}') + + assert item.a == {} + assert item.b is item.c is None