Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ lint = [
"ruff == 0.15.*",
]
typecheck = [
"ty == 0.0.37", # Last version to not error on Returns Result
"ty >= 0.0.65",
]

[tool.uv]
Expand Down
11 changes: 6 additions & 5 deletions src/serialite/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses
from dataclasses import MISSING
from functools import wraps
from typing import get_type_hints
from typing import cast, get_type_hints

from ._base import Serializable, Serializer
from ._descriptors import classproperty
Expand All @@ -15,7 +15,7 @@


# Inspired by https://stackoverflow.com/a/14412901/1485877
def flexible_decorator(dec):
def flexible_decorator[F](dec: F) -> F:
"""A decorator decorator to allow it to be used with or without parameters.

Decorate a decorator like this:
Expand Down Expand Up @@ -59,7 +59,8 @@ def new_dec(*args, **kwargs):
# Decorator called with arguments
return lambda f: dec(f, *args, **kwargs)

return new_dec
# The wrapper accepts the same arguments as the bare decorator, so advertise its signature.
return cast(F, new_dec)


def infer_fields_serializer(cls):
Expand Down Expand Up @@ -105,7 +106,7 @@ def infer_fields_serializer(cls):


@flexible_decorator
def serializable(cls):
def serializable[T](cls: type[T]) -> type[T]:
"""Decorator that provides Serializable interface.

This decorator can be applied to a dataclass. It inserts `SerializableMixin`
Expand Down Expand Up @@ -234,7 +235,7 @@ def infer_subclass_serializers(cls):


@flexible_decorator
def abstract_serializable(cls):
def abstract_serializable[T](cls: type[T]) -> type[T]:
"""Decorator that provides AbstractSerializableMixin interface.

This decorator can be applied to an abstract class. It inserts
Expand Down
3 changes: 1 addition & 2 deletions src/serialite/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ._errors import Errors

Success = result.Success
Failure: type[result.Failure[Errors]] = result.Failure[Errors]
Failure = result.Failure

type Result[Output] = Success[Output] | Failure
type Result[Output] = Success[Output] | Failure[Errors]
44 changes: 22 additions & 22 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading