Add tool to convert binary cache files to JSON#20071
Merged
Conversation
… output JSON Also add tests.
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
approved these changes
Oct 15, 2025
Member
ilevkivskyi
left a comment
There was a problem hiding this comment.
Nice! Thanks for adding this.
Member
|
Test failure on Python 3.9 seems to be caused by |
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work to enable #19697 (see the issue for motivation).
Copy the old
serializemethods with some modifications and use them in the export tool. This will let us remove the oldserializeanddeserializemethods once we drop support for the old JSON serialization format at some point.This should be enough to support existing use cases that inspect the JSON files. Instead of directly inspecting them, users will have to run the tool first if they use the binary cache format. Example:
The run generates the
.mypy_cache/3.13/foobar.data.ff.jsonfile, which is similar to existing to cache json files.I added some tests and manually checked that the JSON file for
builtinsmodule is identical to the one generated by mypy. However, we won't guarantee that all new symbol table or cache features will be added to the exporter, to simplify maintenance. Also I didn't test all features of the exporter in the tests -- I just ensure that the basics work. The tool is primarily there to support existing use cases and debugging workflows, and it would be better to useMypyFile.read(...)in new use cases that require cache inspection.