improve typing for serializer decorator
This commit is contained in:
parent
4a6c16e9dc
commit
c684444561
@ -39,10 +39,24 @@ SERIALIZERS: dict[Type, Serializer] = {}
|
|||||||
SERIALIZER_TYPES: dict[Type, Type] = {}
|
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(
|
def serializer(
|
||||||
fn: Serializer | None = None,
|
fn: Serializer | None = None,
|
||||||
to: Type | None = None,
|
to: Any = None,
|
||||||
) -> Serializer:
|
) -> Serializer | functools.partial[Serializer]:
|
||||||
"""Decorator to add a serializer for a given type.
|
"""Decorator to add a serializer for a given type.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
Loading…
Reference in New Issue
Block a user