Carica

Latest version: v1.3.5

Safety actively analyzes 623871 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 3

1.3.5

What's Changed
* Fix SerializesToType not being a protocol by Trimatix in https://github.com/Trimatix/Carica/pull/80


**Full Changelog**: https://github.com/Trimatix/Carica/compare/v1.3.4...v1.3.5

1.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**: https://github.com/Trimatix/Carica/compare/v1.3.3...v1.3.4

1.3.3

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

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:

py
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:
py
dataclass
class MyClass(SerializableDataClass):
myField: List[str] = TypeOverride(List[int], [])


To solve this issue, the python recommended pattern is now supported:
py
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.

1.3.1

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

1.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 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

Page 1 of 3

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.