From 36a7767bf6ab87b435d374ca64d2b153df7e5607 Mon Sep 17 00:00:00 2001 From: declaresub Date: Tue, 22 Oct 2024 14:37:18 -0400 Subject: [PATCH 1/3] Change type of unstruct_collection_overrides from Mapping[type, Callable] to Mapping[type, UnstructureHookT] in Converter.__init__. With this change, pyright no longer complains that the type of make_converter is partially unknown. --- src/cattrs/converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cattrs/converters.py b/src/cattrs/converters.py index 1218a71d..0c4f00c6 100644 --- a/src/cattrs/converters.py +++ b/src/cattrs/converters.py @@ -1046,7 +1046,7 @@ def __init__( omit_if_default: bool = False, forbid_extra_keys: bool = False, type_overrides: Mapping[type, AttributeOverride] = {}, - unstruct_collection_overrides: Mapping[type, Callable] = {}, + unstruct_collection_overrides: Mapping[type, UnstructureHookT] = {}, prefer_attrib_converters: bool = False, detailed_validation: bool = True, unstructure_fallback_factory: HookFactory[UnstructureHook] = lambda _: identity, From 86fdf2c60f7e1b7fda453ad2856969f0af463c32 Mon Sep 17 00:00:00 2001 From: declaresub Date: Thu, 24 Oct 2024 06:49:09 -0400 Subject: [PATCH 2/3] In Converter.__init__, change type of unstruct_collection_overrides to Mapping[type, UnstructureHook]. --- src/cattrs/converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cattrs/converters.py b/src/cattrs/converters.py index 0c4f00c6..c21f5ea7 100644 --- a/src/cattrs/converters.py +++ b/src/cattrs/converters.py @@ -1046,7 +1046,7 @@ def __init__( omit_if_default: bool = False, forbid_extra_keys: bool = False, type_overrides: Mapping[type, AttributeOverride] = {}, - unstruct_collection_overrides: Mapping[type, UnstructureHookT] = {}, + unstruct_collection_overrides: Mapping[type, UnstructureHook] = {}, prefer_attrib_converters: bool = False, detailed_validation: bool = True, unstructure_fallback_factory: HookFactory[UnstructureHook] = lambda _: identity, From 65f2301d69bddd50ed06d5cdfad69b1a875b365c Mon Sep 17 00:00:00 2001 From: declaresub Date: Thu, 24 Oct 2024 07:01:55 -0400 Subject: [PATCH 3/3] Add item describing PR594. --- HISTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HISTORY.md b/HISTORY.md index 7c7a2300..8bec3ee8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -22,6 +22,7 @@ Our backwards-compatibility policy can be found [here](https://github.com/python - Python 3.13 is now supported. ([#543](https://github.com/python-attrs/cattrs/pull/543) [#547](https://github.com/python-attrs/cattrs/issues/547)) - Python 3.8 is no longer supported, as it is end-of-life. Use previous versions on this Python version. +- Change type of Converter.__init__.unstruct_collection_overrides from Callable to Mapping[type, UnstructureHook] ([#594](https://github.com/python-attrs/cattrs/pull/594). ## 24.1.2 (2024-09-22)