All blark dataclasses from blark.transform should be able to be converted to JSON by way of apischema.serialize
All generated JSON should similarly be able to be transformed back to dataclasses by way of apischema.deserialize
apischema should remain an optional dependency of blark
"JSON" above refers to JSON-serializable data types, including Python built-ins such as dicts, lists, ints, floats, and strings. The conversion of that to an actual serialized JSON string is an additional step.
Issue
During the course of testing, I ran into some issues with apischema on Python 3.9+ (at least according to inline code comments). I wasn't able to get to the heart of the issue to determine a path forward, I merely set up a "skip if on Python 3.9+ or apischema is unavailable".
Failing tests as of 263e263004ae2c03f647743b557f9ab4141b92fe
With APISCHEMA_SKIP set to False on Python 3.9 and blark 263e263004ae2c03f647743b557f9ab4141b92fe, the following tests fail on the serialization portion (at least sometimes due to a recursion error in apischema). apischema=0.17.5, 84 failed, 144 passed, 5 xfailed in 77.86s (0:01:17)
It's likely that the issue is due to mistaken/incorrect type hints. There is at least a tiny possibility that this is an apischema bug.
Type hints for the problematic ones in the failed tests above need reviewing to see what's wrong.
CI should be updated to "run test suite with optional dependencies" and "run test suite without optional dependencies" at some point
Ideally, the round-tripping of code -> dataclass -> code and code -> dataclass -> JSON -> dataclass would be separate in the test suite. As of now, these are only just tacked on in roundtrip_rule.
Goal
blark.transform
should be able to be converted to JSON by way ofapischema.serialize
apischema.deserialize
apischema
should remain an optional dependency of blark"JSON" above refers to JSON-serializable data types, including Python built-ins such as dicts, lists, ints, floats, and strings. The conversion of that to an actual serialized JSON string is an additional step.
Issue
During the course of testing, I ran into some issues with apischema on Python 3.9+ (at least according to inline code comments). I wasn't able to get to the heart of the issue to determine a path forward, I merely set up a "skip if on Python 3.9+ or apischema is unavailable".
Test suite reference: https://github.com/klauer/blark/blob/263e263004ae2c03f647743b557f9ab4141b92fe/blark/tests/test_transformer.py#L19-L21
Optional dependency in the transformer dataclass section: https://github.com/klauer/blark/blob/263e263004ae2c03f647743b557f9ab4141b92fe/blark/transform.py#L18-L28
Failing tests as of 263e263004ae2c03f647743b557f9ab4141b92fe
With
APISCHEMA_SKIP
set toFalse
on Python 3.9 and blark 263e263004ae2c03f647743b557f9ab4141b92fe, the following tests fail on the serialization portion (at least sometimes due to a recursion error in apischema). apischema=0.17.5,84 failed, 144 passed, 5 xfailed in 77.86s (0:01:17)
Random thoughts
code -> dataclass -> code
andcode -> dataclass -> JSON -> dataclass
would be separate in the test suite. As of now, these are only just tacked on inroundtrip_rule
.