Closed VincentVanlaer closed 7 months ago
Hm how about we change the tagged union strategy to take a BaseConverter instead? I don't remember why I made it take a Converter, maybe it's an easy fix.
It seems like the tagged union strategy only uses methods on BaseConverter
, so changing that seems fine. In the meantime I realized it might make more sense to type include_subclasses
as
C = TypeVar("C", bound=BaseConverter)
def include_subclasses(
cl: Type,
converter: C,
subclasses: Optional[Tuple[Type, ...]] = None,
union_strategy: Optional[Callable[[Any, C], Any]] = None,
overrides: Optional[Dict[str, AttributeOverride]] = None,
) -> None:
since the argument passed to the union strategy is the same as is passed to include_subclasses
. But that might be overkill for this situation. Let me know whether you prefer just the change to the tagged union strategy or also for include_subclasses
.
I'd be ok with changing both!
Sorry for the delay, I was focused on getting 23.2 out the door which is now done.
No worries! I have included both changes and I checked with mypy that no new errors emerged.
Sweet! Can you add a small line to HISTORY?
I missed your last comment! Should be ready now.
Thanks!
Using Converter instead of BaseConverter as one of the arguments to union_strategy allows more strategies to be passed. Specifically, the configure_tagged_union strategy currently requires a Converter according to its typing.