Skip to content

Releases: yukinarit/pyserde

v0.9.6

05 Dec 14:15
648471c
Compare
Choose a tag to compare
  • Recursive dataclasses are supported in #290
    @dataclass
    class Recur:
        f: Optional['Recur']
    
    serde(Recur)
  • typing.FrozenSet and typing.DefaultDict are supported in #285,#286
    @serde
    @dataclass
    class Foo:
        a: FrozenSet[int]
        b: DefaultDict[str, List[int]]
  • Pickle serializer and deserializer support is added in #284. Thanks @DoeringChristian!

Full Changelog: v0.9.5...v0.9.6

v0.9.5

26 Nov 13:26
d52d7af
Compare
Choose a tag to compare

alias field attribute was implemented.

@serde
@dataclass
class Foo:
    a: int = field(alias=["b", "c", "d"])
  • feat: Implement alias (36cbc6e)
  • test: Add InitVar and ClassVar examples (f5171fa)
  • build: Add python 3.11 to pyproject.toml (4ea7504)

v0.9.4

20 Nov 11:53
3e6e1ba
Compare
Choose a tag to compare

Variable lengh tuple is supported.

@serde
@dataclass
class Foo:
    v: Tuple[int, ...]
  • feat: Support variable length tuples (74dd3d4)
  • feat: Use tomllib for Python >= 3.11 (b8943b5)

v0.9.3

10 Nov 14:46
889e6ab
Compare
Choose a tag to compare

Thanks to PEP681 @dataclass_transform, @dataclass decorator is no longer mandatory if you use a PEP681 supported type checker such as pyright. If you are a mypy user, you still need @dataclass decorator.

@serde
#@dataclass <= No longer needed.
class Foo:
    i: int
  • ci: Build with python 3.11 on CI (a8def55)
  • feat: pep681 (4ec2bf8)
  • fix: Mypy type errors (3ac1510)
  • fix: Support nested generic dataclasses (3562139)

v0.9.2

03 Sep 11:31
88be343
Compare
Choose a tag to compare
  • chore: Bump allowed version of numpy to >1.21.0 on Python 3.7 (beb2a8b)
  • fix: Fix deserialization of optional complex types with default=None (2b3b7ae)

This release had contributions from 1 person: @kmsquire. Thank you so much! 🎉 😂

v0.9.1

30 Aug 13:49
1f48c9c
Compare
Choose a tag to compare
  • fix: Call to untyped function "serde" in typed context (84c5f07)

v0.9.0

26 Aug 14:32
d42e058
Compare
Choose a tag to compare

pyserde v0.9 adds one of the most awaited features, the type checking functionality 🎉 If you add Coerce or Strict in serde decorator, pyserde will do type coercing or type checking based on the declared types.

Coerce

Type coercing automatically converts a value into the declared type during (de)serialization. If the value is incompatible e.g. value is "foo" and type is int, pyserde raises an SerdeError.

@serde(type_check=Coerce)
@dataclass
class Foo
    s: str

foo = Foo(10)
# pyserde automatically coerce the int value 10 into "10".
# {"s": "10"} will be printed.
print(to_json(foo))
Strict

Strict type checking is to check every value against the declared type during (de)serialization. We plan to make Strict a default type checker in the future release.

@serde(type_check=Strict)
@dataclass
class Foo
    s: str

foo = Foo(10)
# pyserde checks the value 10 is instance of `str`.
# SerdeError will be raised in this case because of the type mismatch.
print(to_json(foo))
  • refactor: Change default type_check from Coerce to NoCheck (23ea180)
  • refactor: Change to pass "type_check" parameter in decorator (fbe8dc8)
  • feat: Add type coercion feature make it default (dabb777)
  • feat: Implement strict type checking (0273b9a)

Another notable change is switching toml library from toml to tomli. tomli is used in a handful of major products e.g. pip and pytest and will be the part of Python standard library in Python 3.11.

  • feat: Switch toml library to tomli (11b4df6)
  • Better documentation about generic alias (fd4e5a5)
  • Ensure union_func_name produces a valid function name (eddf250)
  • Import 'Literal' from serde.compat (a7450c1)
  • Support NumPy 1.23 in Python 3.7/3.8 (3309a73)
  • Use str instead of repr in typename, fixing Union[Literal["str"], ...] (b3905ef)
  • fix: from_json return returns T not Optional[T] (9e50fb7)

This release had contributions from 1 person: @kngwyu. Thank you so much! 🎉 😂

v0.8.3

28 Jun 12:46
e313fa8
Compare
Choose a tag to compare
  • fix: Use numpy<1.23.0 for python 3.7 and 3.8 (3045521)

v0.8.2

18 Jun 02:32
90c0871
Compare
Choose a tag to compare
  • chore: Replace stringcase with casfey (1f8a17d), closes #240

This release had a contribution from 1 person: @gitpushdashf. Thank you so much! 🎉 😂

v0.8.1

15 Jun 00:06
ace00ad
Compare
Choose a tag to compare
  • feat: Don't wrap user exception in SerdeError (161cffd)