Releases: Trimatix/Carica
Patch v1.3.5
What's Changed
Full Changelog: v1.3.4...v1.3.5
Patch v1.3.4
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
This patch fixes a bug that prevented dataclass fields from being container types, containing custom serializable classes.
Patch v.1.3.2
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
This hot fix adds some missing generic parameterization on SerializableType.deserialize
, to reflect the addition to ISerializable.deserialize
.
Release v1.3
- 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 justISerializable
- Do the same for exposed models, such as
SerializableDataClass
- Fix
deserializeValues
kwarg forSerializableDataClass.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 whosedeserialize
returns a (potentially multi-layer) Dict with only strings as keys
- Fix
None
not being included inPrimativeTypes
alias
Patch v1.2.2
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
This patch fixes the package installer.
Previously, the package simply was not installed, neither was its dependencies.
Release v1.2.0
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
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.