Skip to content

Conversation

@xingarr
Copy link

@xingarr xingarr commented Nov 4, 2025

  • Add robust error handling for orjson import and usage
  • Implement comprehensive fallback mechanism when orjson is unavailable
  • Add performance benchmarking utilities for JSON operations (mypy.json_bench)
  • Include comprehensive test suite with 18 tests for edge cases
  • Document performance characteristics and usage patterns
  • Improve error handling for large integers exceeding 64-bit range
  • Add detailed documentation explaining cache consistency requirements

This enhancement improves the faster-cache feature reliability and provides better visibility into JSON serialization performance, which is critical for mypy's incremental type checking caching mechanisms.

Resolves TODO items in mypy/util.py related to JSON optimization and sorted keys requirement documentation.

(Explain how this PR changes mypy.)

xingarr and others added 2 commits November 4, 2025 15:20
- Add robust error handling for orjson import and usage
- Implement comprehensive fallback mechanism when orjson is unavailable
- Add performance benchmarking utilities for JSON operations (mypy.json_bench)
- Include comprehensive test suite with 18 tests for edge cases
- Document performance characteristics and usage patterns
- Improve error handling for large integers exceeding 64-bit range
- Add detailed documentation explaining cache consistency requirements

This enhancement improves the faster-cache feature reliability and provides
better visibility into JSON serialization performance, which is critical for
mypy's incremental type checking caching mechanisms.

Resolves TODO items in mypy/util.py related to JSON optimization and
sorted keys requirement documentation.
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 4, 2025

We are moving from JSON serialization to a binary serialization format with a separate tool to convert binary cache files to JSON. The new format is currently enabled using --fixed-format-cache, but we are planning to make it the default (and eventually only) format within the next few releases. Unfortunately, it seems that this is not something that we need.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks! This is a much larger diff than needed; if you are seeing an exception on load or dump, could you describe exactly what you are seeing? If so, open to a diff that only has the exception handling changes

@xingarr
Copy link
Author

xingarr commented Nov 4, 2025

THanks for your review, so what you want me to update in this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants