Releases: malcolmgreaves/pywise
Releases · malcolmgreaves/pywise
0.8.1
What's Changed
- Update lockfile by @malcolmgreaves in #33
- [0.8.1] Better name:
from core_utils.timing import timer
by @malcolmgreaves in #34
Full Changelog: 0.8.0...0.8.1
0.8.0
What's Changed
- [0.8.0] WritableFile protocol in new io_utils module by @malcolmgreaves in #32
Full Changelog: 0.7.0...0.8.0
0.7.0
What's Changed
- Update README docs for devtools use by @malcolmgreaves in #31
- [0.7.0] flatten arbitrarily nested iterables by @malcolmgreaves in #7
- Update description and license in Python project metadata.
Full Changelog: 0.6.0...0.7.0
0.6.0
Lots of new features!
What's Changed
- Added pre-commit as dev dependency & established existing CI checks as hooks by @malcolmgreaves in #24
- Migrate to use
ruff
+ standardpre-commit-hooks
(Python,JSON,YAML) by @malcolmgreaves in #26 - ruff pre-commit hook uses pyproject.toml config by @malcolmgreaves in #27
- [0.6.0] new features, dev tools overall, testing coverage push by @malcolmgreaves in #29
- Update poetry lockfile by @malcolmgreaves in #30
Full Changelog: 0.5.0...0.6.0
0.5.0
What's Changed
- Maintenance: support Python 3.{9,10,11}, drop 3.7 support & update dev. reps. by @malcolmgreaves in #20
Full Changelog: 0.4.0...0.5.0
Deserialize Handles Default Values
Adds support to deserialize
to handle types that have default values on one or more fields. When a field-value pair is not found during deserialize
, it will use the type's defined default value for the field as the value
. Supports arbitrary nesting of default values.
Thus the following will work now as of 0.4.0
:
from dataclasses import dataclass
from core_utils.serialization import *
@dataclass(frozen=True)
class Hello:
name: str
value: int = 42
assert deserialize(Hello, {'name': 'world'}) == Hello(name="world", value=42)
Deserialize Generics/Collections in Union Types
Bugfix: support for properly deserializing Union types that contain generics (e.g. collection types such as List
, Dict
, etc.). In general, the following will work now:
deserialize(Union[A[B], C[D]], x)
For @dataclass(frozen=True) class A(Generic[B])
and @dataclass(frozen=True) class C(Generic[D])
.
0.3.1: Bugfix deserialize when no generics are present (#6)
The deserialize update from version `0.3.0` had a bug where a @dataclass with parameterized types that _did not have any fields using the generic types_ would fail deserialization. This bug was introduced due to an assumption that all non-leaf nodes of the generic @dataclass type's AST would have at least one parameterized generic. The `_dataclass_field_types` function in the `serialization` module has been updated to account for this (rather common) case. New tests have been added to cover this functionality. Additionally, the `type_name` function in the `common` module has been updated to properly handle `typing.Any`, since it has a unique `_SpecialForm` backing. A new test case has been added to address `Any`. Version `0.3.1`.
0.3.0
Enable deserialization support for dataclasses with generic types (#5) Upgrades `deserialize` (and `serialize`) to handle @dataclass types parameterized with generics. Under the hood, the new `_align_generic_concrete`, `_fill`, and `_exec` functions in the `serialization` module handle reifying the parameterized type information at runtime. These new functions modify `_dataclass_field_types` to properly support "filling-in" the generic "holes" and output fully specified types. Extensive tests have been added to explicitly test deserialization from generic @dataclass types, including a very deeply nested example. Note that it's not possible to support generics in `NamedTuple` deriving types. I.e. if given `class X(NamedTuple,Generic[T]):...` then `X[int]` is an invalid expression in Python. Since such expressions cannot be used, it's not possible to parametrize the generic types and thus it is not possible to gather reified type information at runtime. This is a major API change: pre `1.x.x` rules dictate a minor version bump to `0.3.0`.
0.2.0
Do not serialize None values (#3) Changes the default behavior of `serialize` to not explicitly serialize values that are `None` in `@dataclass`es, `NamedTuple`-derriving classes, or key-value `Mapping`s. When combining with JSON serialization, this will prevent a `"field_name": null` object key-value mapping from coming up. To explicitly serialize `None` values (i.e. the old behavior), the new `no_none_values` flag can be set to `False`. New tests have been added to cover this new behavior. Major API change, but in keeping with Semantic Versioning 2.0 rules for pre-releases (`0.x.x`), new version is `0.2.0`.