v0.12.0
What's Changed
New features
- Union directly by @yukinarit in #339
This example works correctly now
@serde
@dataclass
class Foo:
a: int
@serde
@dataclass
class Bar:
a: int
bar = Bar(10)
s = to_json(bar)
print(s)
print(from_json(Union[Foo, Bar], s))
However, This will introduce a breaking change!! The default behaviour when you pass Union directly was "Untagged" until v0.11.1, but since v0.12.0 it is "ExternalTagging".
The following code prints {"a": 10}
until v0.11.1, but prints {"Bar": {"a": 10}}
since v0.12.0
print(to_json(bar))
For more information about Union, please see the docs
Refactoring
- Fix mypy/pyright errors in serde/inspect.py by @yukinarit in #401
- Fix mypy/pyright errors in serde/init.py by @yukinarit in #402
- Fix mypy/pyright errors in serde/compat.py by @yukinarit in #403
Other changes
- Change line length from 120 to 100 by @yukinarit in #391
Full Changelog: v0.11.1...v0.12.0