|
1 | | -## `0.8.3` (2022-06-28) |
| 1 | +## `0.9.0` (2022-08-26) |
| 2 | + |
| 3 | +`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. |
| 4 | + |
| 5 | +##### `Coerce` |
| 6 | + |
| 7 | +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`. |
| 8 | + |
| 9 | +```python |
| 10 | +@serde(type_check=Coerce) |
| 11 | +@dataclass |
| 12 | +class Foo |
| 13 | + s: str |
| 14 | + |
| 15 | +foo = Foo(10) |
| 16 | +# pyserde automatically coerce the int value 10 into "10". |
| 17 | +# {"s": "10"} will be printed. |
| 18 | +print(to_json(foo)) |
| 19 | +``` |
| 20 | + |
| 21 | +##### `Strict` |
| 22 | + |
| 23 | +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. |
| 24 | + |
| 25 | +```python |
| 26 | +@serde(type_check=Strict) |
| 27 | +@dataclass |
| 28 | +class Foo |
| 29 | + s: str |
| 30 | + |
| 31 | +foo = Foo(10) |
| 32 | +# pyserde checks the value 10 is instance of `str`. |
| 33 | +# SerdeError will be raised in this case because of the type mismatch. |
| 34 | +print(to_json(foo)) |
| 35 | +``` |
| 36 | + |
| 37 | +* refactor: Change default type_check from Coerce to NoCheck ([23ea180](https://github.com/yukinarit/pyserde/commit/23ea180)) |
| 38 | +* refactor: Change to pass "type_check" parameter in decorator ([fbe8dc8](https://github.com/yukinarit/pyserde/commit/fbe8dc8)) |
| 39 | +* feat: Add type coercion feature make it default ([dabb777](https://github.com/yukinarit/pyserde/commit/dabb777)) |
| 40 | +* feat: Implement strict type checking ([0273b9a](https://github.com/yukinarit/pyserde/commit/0273b9a)) |
| 41 | + |
| 42 | +Another notable change is switching toml library from [toml](https://pypi.org/project/toml/) to [tomli](https://pypi.org/project/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](https://peps.python.org/pep-0680/). |
| 43 | + |
| 44 | +* feat: Switch toml library to tomli ([11b4df6](https://github.com/yukinarit/pyserde/commit/11b4df6)) |
| 45 | +* Better documentation about generic alias ([fd4e5a5](https://github.com/yukinarit/pyserde/commit/fd4e5a5)) |
| 46 | +* Ensure union_func_name produces a valid function name ([eddf250](https://github.com/yukinarit/pyserde/commit/eddf250)) |
| 47 | +* Import 'Literal' from serde.compat ([a7450c1](https://github.com/yukinarit/pyserde/commit/a7450c1)) |
| 48 | +* Support NumPy 1.23 in Python 3.7/3.8 ([3309a73](https://github.com/yukinarit/pyserde/commit/3309a73)) |
| 49 | +* Use str instead of repr in typename, fixing Union[Literal["str"], ...] ([b3905ef](https://github.com/yukinarit/pyserde/commit/b3905ef)) |
| 50 | +* fix: from_json return returns T not Optional[T] ([9e50fb7](https://github.com/yukinarit/pyserde/commit/9e50fb7)) |
| 51 | + |
| 52 | +This release had contributions from 1 person: [@kngwyu](https://github.com/kngwyu). Thank you so much! :tada: :joy: |
| 53 | + |
| 54 | +## `0.8.3` (2022-06-28) |
2 | 55 |
|
3 | 56 | * fix: Use numpy<1.23.0 for python 3.7 and 3.8 ([3045521](https://github.com/yukinarit/pyserde/commit/3045521)) |
4 | 57 |
|
|
0 commit comments