GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix the exportjson tool (.ff cache to .json conversion) by JukkaL · Pull Request #21628 · python/mypy

Fix the exportjson tool (.ff cache to .json conversion) #21628

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.

Sign up for GitHub

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

Merged
JukkaL merged 1 commit into master from fix-export-json
Jun 19, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Fix the exportjson tool (.ff cache to .json conversion) #21628

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
2ccaa17
Fix the exportjson tool (.ff cache to .json conversion)
JukkaL Jun 19, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Fix the exportjson tool (.ff cache to .json conversion)
It was broken by lazy cache deserialization, and the test didn't
catch it since the fixup state was persisted within the test.
Both fix the exportjson tool and make the test more realistic.
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@JukkaL
JukkaL committed Jun 19, 2026
commit 2ccaa177d6afd0a275cf8d8dc93f1cb05958f8c5

There are no files selected for viewing

8 changes: 6 additions & 2 deletions 8 mypy/exportjson.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ def convert_symbol_table_node(self: SymbolTableNode, cfg: Config) -> Json:
data["plugin_generated"] = True
if self.cross_ref:
data["cross_ref"] = self.cross_ref
elif self.node is not None:
data["node"] = convert_symbol_node(self.node, cfg)
else:
# Read the raw node without cross-reference fixup, since exportjson reads
# cache files in isolation and no node fixer is available.
node = self.read_node_no_fixup()
if node is not None:
data["node"] = convert_symbol_node(node, cfg)
return data


Expand Down
11 changes: 11 additions & 0 deletions 11 mypy/nodes.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4952,6 +4952,17 @@ def node(self) -> SymbolNode | None:
self.unfixed = False
return self._node

def read_node_no_fixup(self) -> SymbolNode | None:
"""Return the deserialized node without performing cross-reference fixup.

This is intended for introspection tools (such as mypy.exportjson) that read
cache files in isolation, where no node fixer is available.
"""
if self._node is None and self._node_bytes:
self._node = read_symbol(ReadBuffer(self._node_bytes), self._node_tag)
self._node_bytes = b""
return self._node

def copy(self) -> SymbolTableNode:
new = SymbolTableNode(
self.kind, self._node, self.module_public, self.implicit, self.module_hidden
Expand Down
6 changes: 6 additions & 0 deletions 6 mypy/test/testexportjson.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from mypy.errors import CompileError
from mypy.exportjson import convert_binary_cache_meta_to_json, convert_binary_cache_to_json
from mypy.modulefinder import BuildSource
from mypy.modules_state import modules_state
from mypy.options import Options
from mypy.test.config import test_temp_dir
from mypy.test.data import DataDrivenTestCase, DataSuite
Expand Down Expand Up @@ -44,6 +45,11 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
major, minor = sys.version_info[:2]
cache_dir = os.path.join(".mypy_cache", f"{major}.{minor}")

# Reset the global fixup state, since the exportjson tool
# reads cache files in isolation (no node fixer available).
modules_state.node_fixer = None
modules_state.modules = {}

for module in result.files:
if module in (
"builtins",
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.