Skip to content
Open
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
3 changes: 1 addition & 2 deletions examples/forward_reference.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from dataclasses import dataclass

from serde import serde
from serde.json import from_json, to_json

Expand Down
8 changes: 2 additions & 6 deletions examples/generics.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
from typing import Generic, TypeVar

from serde import from_dict, serde, to_dict

T = TypeVar("T")


@serde
class Bar:
n: int


@serde
class Foo(Generic[T]):
class Foo[T]:
inner: T


@serde
class Baz(Generic[T]):
class Baz[T]:
foo: Foo[T]


Expand Down
8 changes: 2 additions & 6 deletions examples/generics_nested.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Generic, TypeVar

from serde import from_dict, serde, to_dict


Expand All @@ -15,17 +13,15 @@ class A(EventData):

# Additional subclasses of EventData exist

Data = TypeVar("Data", bound=EventData)


@serde
class Payload(Generic[Data]):
class Payload[Data: EventData]:
id: int
data: Data


@serde
class Event(Generic[Data]):
class Event[Data: EventData]:
name: str
payload: Payload[Data]

Expand Down
8 changes: 6 additions & 2 deletions examples/generics_pep695.py → examples/generics_typing.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
from typing import Generic, TypeVar

from serde import from_dict, serde, to_dict

T = TypeVar("T")


@serde
class Bar:
n: int


@serde
class Foo[T]:
class Foo(Generic[T]):
inner: T


@serde
class Baz[T]:
class Baz(Generic[T]):
foo: Foo[T]


Expand Down
2 changes: 0 additions & 2 deletions examples/lazy_type_evaluation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from serde import serde
from serde.json import from_json, to_json

Expand Down
1 change: 0 additions & 1 deletion examples/recursive.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
from dataclasses import dataclass

from serde import from_dict, serde, to_dict
Expand Down
1 change: 0 additions & 1 deletion examples/recursive_list.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import annotations
from dataclasses import dataclass

from serde import serde
Expand Down
4 changes: 2 additions & 2 deletions examples/recursive_union.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
from serde import serde, to_dict, InternalTagging, from_dict
from dataclasses import dataclass

from serde import InternalTagging, from_dict, serde, to_dict


@serde(tagging=InternalTagging("type"))
@dataclass
Expand Down
4 changes: 2 additions & 2 deletions examples/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import typing


if sys.version_info[:3] < (3, 12, 0):
print("examples require at least Python 3.12")
if sys.version_info[:3] < (3, 14, 0):
print("examples require at least Python 3.14")
sys.exit(1)


Expand Down
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ include = [
exclude = [
"serde/numpy.py",
"serde/__init__.py",
"examples/type_numpy_jaxtyping.py"
"examples/type_numpy_jaxtyping.py",
"examples/forward_reference.py",
"examples/recursive.py",
"examples/recursive_list.py",
"examples/recursive_union.py",
"examples/lazy_type_evaluation.py",
]
pythonVersion = "3.12"
reportMissingImports = false
Expand All @@ -134,7 +139,8 @@ ignore_missing_imports = true
exclude = [
"serde/numpy.py",
"examples/alias.py",
"examples/generics_pep695.py",
"examples/generics.py",
"examples/generics_nested.py",
"examples/custom_class_serializer.py",
"examples/global_custom_class_serializer.py",
"tests/.*",
Expand All @@ -150,9 +156,15 @@ ignore_errors = true
[tool.ruff]
line-length = 100
extend-exclude = [
"examples/generics_pep695.py",
"examples/generics.py",
"examples/generics_nested.py",
"examples/type_alias_pep695.py",
"examples/type_statement.py",
"examples/forward_reference.py",
"examples/recursive.py",
"examples/recursive_list.py",
"examples/recursive_union.py",
"examples/lazy_type_evaluation.py",
]

[tool.ruff.lint]
Expand Down
Loading