Skip to content

Releases: malcolmgreaves/pywise

0.8.1

02 Jun 17:40
2689939
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.8.0...0.8.1

0.8.0

02 Jun 17:15
842393e
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.7.0...0.8.0

0.7.0

30 May 07:45
904906d
Compare
Choose a tag to compare

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

30 May 06:58
6286764
Compare
Choose a tag to compare

Lots of new features!

What's Changed

Full Changelog: 0.5.0...0.6.0

0.5.0

30 May 06:58
Compare
Choose a tag to compare

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

09 Mar 03:30
Compare
Choose a tag to compare

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

20 Jan 06:27
5d0f77d
Compare
Choose a tag to compare

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)

09 Sep 06:26
53259ef
Compare
Choose a tag to compare
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

09 Sep 06:20
b7c791c
Compare
Choose a tag to compare
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

25 Aug 19:47
651d3ba
Compare
Choose a tag to compare
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`.