Skip to content

refactor: Improve JsonSerializable type to be recursive#745

Merged
vdusek merged 1 commit into
masterfrom
refactor/recursive-json-serializable-type
Apr 21, 2026
Merged

refactor: Improve JsonSerializable type to be recursive#745
vdusek merged 1 commit into
masterfrom
refactor/recursive-json-serializable-type

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 21, 2026

Summary

Replace the loose dict[str, Any] | list[Any] variants of JsonSerializable with recursive references so nested JSON values are properly typed instead of falling back to Any. Based on the definition discussed in python/typing#182.

Replace the loose `dict[str, Any] | list[Any]` variants with recursive references so nested
JSON values are now properly typed instead of falling back to `Any`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Apr 21, 2026
@vdusek vdusek self-assigned this Apr 21, 2026
@github-actions github-actions Bot added this to the 139th sprint - Tooling team milestone Apr 21, 2026
@vdusek vdusek requested a review from janbuchar April 21, 2026 07:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.29%. Comparing base (6c3b84d) to head (73ae4bd).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #745      +/-   ##
==========================================
- Coverage   95.36%   95.29%   -0.08%     
==========================================
  Files          45       45              
  Lines        5118     5118              
==========================================
- Hits         4881     4877       -4     
- Misses        237      241       +4     
Flag Coverage Δ
integration 95.29% <100.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the public interface via UserData, right? So the change is technically breaking for users of type checkers that cannot handle recursive types. Do we consider it a problem?

@vdusek
Copy link
Copy Markdown
Contributor Author

vdusek commented Apr 21, 2026

See this comment from the end of 2022:

All major type checkers now support recursive type aliases by default, so this should largely work:

JSON: TypeAlias = dict[str, "JSON"] | list["JSON"] | str | int | float | bool | None

So I wouldn't be afraid of it.

Copy link
Copy Markdown
Contributor

@janbuchar janbuchar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM then!

@vdusek vdusek merged commit 6b8001e into master Apr 21, 2026
26 checks passed
@vdusek vdusek deleted the refactor/recursive-json-serializable-type branch April 21, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants