improve typing for serializer decorator

This commit is contained in:
Benedikt Bartscher 2024-11-07 01:01:22 +01:00
parent 4a6c16e9dc
commit c684444561
No known key found for this signature in database

View File

@ -39,10 +39,24 @@ SERIALIZERS: dict[Type, Serializer] = {}
SERIALIZER_TYPES: dict[Type, Type] = {}
@overload
def serializer(
fn: None = None,
to: Any = None,
) -> Serializer: ...
@overload
def serializer(
fn: Serializer,
to: None = None,
) -> functools.partial[Serializer]: ...
def serializer(
fn: Serializer | None = None,
to: Type | None = None,
) -> Serializer:
to: Any = None,
) -> Serializer | functools.partial[Serializer]:
"""Decorator to add a serializer for a given type.
Args: