Skip to content

Releases: Trimatix/Carica

Patch v1.3.5

24 Jul 06:06
1ca0086
Compare
Choose a tag to compare

What's Changed

  • Fix SerializesToType not being a protocol by @Trimatix in #80

Full Changelog: v1.3.4...v1.3.5

Patch v1.3.4

21 May 21:54
1050819
Compare
Choose a tag to compare

What's Changed

  • Fix dataclass serializer
  • Fix workflow status badge in readme
  • Fix non-wrapped types not being written to cfg module
  • Fix TOMLKit tables not being recognised
  • Unwrap tomlkit array types

Full Changelog: v1.3.3...v1.3.4

Patch v1.3.3

20 Jul 23:06
Compare
Choose a tag to compare

This patch fixes a bug that prevented dataclass fields from being container types, containing custom serializable classes.

Patch v.1.3.2

20 Jun 22:23
8ab95db
Compare
Choose a tag to compare

This patch allows for TypeOverrides in SerializableDataClassFields to have mutable default values.

Python's dataclasses do not allow for mutable default values, otherwise instances that use the default will all point to the same object:

@dataclass
class MyClass:
    myField: List[str] = []

The above will throw an exception (even without instancing the class)
The same exception will be thrown when the type is overridden in Carica:

@dataclass
class MyClass(SerializableDataClass):
    myField: List[str] = TypeOverride(List[int], [])

To solve this issue, the python recommended pattern is now supported:

from dataclasses import field

@dataclass
class MyClass(SerializableDataClass):
    myField: List[str] = field(default_factory=TypeOverride(List[int], list))

no more errors :)
The factory (given as the second argument to TypeOverride here) can be any callable, as long as it returns your hinted type. lambdas work great here.

Hot Fix v1.3.1

19 Jun 12:17
fc16290
Compare
Choose a tag to compare

This hot fix adds some missing generic parameterization on SerializableType.deserialize, to reflect the addition to ISerializable.deserialize.

Release v1.3

19 Jun 11:56
45e5eb6
Compare
Choose a tag to compare
  • Add TypeOverride to tell Carica and the type checker different things
    • Carica will deserialize to the overridden type, but your type checker will still see the original type
  • Switch from mypy for type checking to pyright
  • Parameterize ISerializable
    • ISerializable.deserialize for subclasses is now typed to return your subclass instead of just ISerializable
    • Do the same for exposed models, such as SerializableDataClass
  • Fix deserializeValues kwarg for SerializableDataClass.deserialize not being respected
  • Add SerializesToType generic
    • Use to specify that a hinted type should serialize to a particular primative
    • Add SerializesToDict as an example - shorthand for any class whose deserialize returns a (potentially multi-layer) Dict with only strings as keys
  • Fix None not being included in PrimativeTypes alias

Patch v1.2.2

16 May 11:09
7a6ae59
Compare
Choose a tag to compare

This patch fixes deserializing serialized datetime. TomlKit will deserialize into its own time, tomlkit.items.DateTime, which is then rejected by the Carica deserializer. This release fixes this issue by allowing subclasses during type checking, instead of forcing exact type matching.

Patch v1.2.1

01 Apr 20:09
Compare
Choose a tag to compare

This patch fixes the package installer.
Previously, the package simply was not installed, neither was its dependencies.

Release v1.2.0

13 Nov 13:03
074be16
Compare
Choose a tag to compare

Allow generic SerializableDataClass field Unions
previously, due to the computational complexity and ambiguity of choosing the best candidate of a Union type hint, Unions were prohibited from being generic. This release allows generic Union hints of arbitrary depth by enforcing a 'first fit' policy instead of 'best fit'.

Release v1.1.0

10 Nov 23:28
c006c9b
Compare
Choose a tag to compare

Enabled the SerializableDataClass prebuilt model.

SerializableDataClass will now inspect the type hints of its fields and intelligently type check incoming serialized objects, traversing the type hints recursively to allow for very granular typing.