Skip to content

extend the Encoder/Decoder state API to be type-aware #13017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thrau
Copy link
Member

@thrau thrau commented Aug 18, 2025

Motivation

Currently our decoders serve as adapter only to dill pickle. Because they type information is stored in the pickle, you can de-serialize a pickle and get the correct type without having to specify it at deserialization. Unfortunately this process breaks down when you've moved or renamed a class that you want to deserialize into.

So to be able to de-couple code and data serialization, and separate reader/writer schema, we need the decoder to be type-aware. The Encoder has to be type aware for certain operations as well, for example if we pass a TypedDict to encode, we won't know which type to encode since python doesn't retain type information for typed dicts. So this is just to make the encoding API a more flexible.

Changes

  • state Encoder and Decoder APIs now optionally take a expected_type argument that allows an underlying implementation to be specific about the python type to serialize or deserialize into

Copy link

Test Results - Preflight, Unit

0 tests   - 22 139   0 ✅  - 20 404   0s ⏱️ - 6m 16s
0 suites  -      1   0 💤  -  1 735 
0 files    -      1   0 ❌ ±     0 

Results for commit 76962b3. ± Comparison against base commit 13b1055.

@thrau thrau added the semver: patch Non-breaking changes which can be included in patch releases label Aug 18, 2025
Copy link

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 41m 54s ⏱️ - 4m 32s
4 630 tests ±0  4 190 ✅ ±0  440 💤 ±0  0 ❌ ±0 
4 632 runs  ±0  4 190 ✅ ±0  442 💤 ±0  0 ❌ ±0 

Results for commit 76962b3. ± Comparison against base commit 13b1055.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant