From 074fa61a039c4224f245fcceb796e3faf30868eb Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Tue, 21 Nov 2023 23:12:46 +0100 Subject: [PATCH] Relax Converter type on configure_tagged_union --- HISTORY.md | 2 ++ src/cattrs/strategies/_unions.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index b4839b54..49ad4db4 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -51,6 +51,8 @@ Our backwards-compatibility policy can be found [here](https://github.com/python - The documentation has been significantly reworked. ([#473](https://github.com/python-attrs/cattrs/pull/473)) - The docs now use the Inter font. +- Make type annotations for `include_subclasses` and `tagged_union` more lenient. + ([#431](https://github.com/python-attrs/cattrs/pull/431)) ## 23.2.3 (2023-11-30) diff --git a/src/cattrs/strategies/_unions.py b/src/cattrs/strategies/_unions.py index 1e63744d..a6f07705 100644 --- a/src/cattrs/strategies/_unions.py +++ b/src/cattrs/strategies/_unions.py @@ -3,7 +3,7 @@ from attrs import NOTHING -from cattrs import BaseConverter, Converter +from cattrs import BaseConverter from cattrs._compat import get_newtype_base, is_literal, is_subclass, is_union_type __all__ = [ @@ -20,7 +20,7 @@ def default_tag_generator(typ: Type) -> str: def configure_tagged_union( union: Any, - converter: Converter, + converter: BaseConverter, tag_generator: Callable[[Type], str] = default_tag_generator, tag_name: str = "_type", default: Optional[Type] = NOTHING,