add to= type for serializers

This commit is contained in:
Masen Furer 2024-11-06 16:34:38 -08:00
parent a493b70fad
commit 3de041629c
No known key found for this signature in database
GPG Key ID: 2AE2BD5531FF94F4

View File

@ -463,7 +463,7 @@ K = TypeVar("K")
V = TypeVar("V")
@serializer
@serializer(to=list)
def serialize_Sequence(s: Sequence[T] | MutableSet[T]) -> list[T]:
"""Serialize a sequence or mutable set as a regular list.
@ -476,7 +476,7 @@ def serialize_Sequence(s: Sequence[T] | MutableSet[T]) -> list[T]:
return list(s)
@serializer
@serializer(to=dict)
def serialize_Mapping(m: Mapping[K, V]) -> dict[K, V]:
"""Serialize a mapping as a regular dictionary.
@ -489,7 +489,7 @@ def serialize_Mapping(m: Mapping[K, V]) -> dict[K, V]:
return dict(m)
@serializer
@serializer(to=dict)
def serialize_DeclarativeBase(obj: DeclarativeBase) -> dict[str, str]:
"""Serialize a SQLAlchemy DeclarativeBase object as a dictionary.