Skip to content
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

Add --debug-serialize option #14155

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,12 @@ def write_cache(self) -> None:
or self.options.cache_dir == os.devnull
or self.options.fine_grained_incremental
):
if self.options.debug_serialize:
try:
self.tree.serialize()
except Exception:
print(f"Error serializing {self.id}", file=self.manager.stdout)
raise # Propagate to display traceback
return
is_errors = self.transitive_error
if is_errors:
Expand Down
3 changes: 3 additions & 0 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,9 @@ def add_invertible_flag(
parser.add_argument(
"--cache-map", nargs="+", dest="special-opts:cache_map", help=argparse.SUPPRESS
)
# --debug-serialize will run tree.serialize() even if cache generation is disabled.
# Useful for mypy_primer to detect serialize errors earlier.
parser.add_argument("--debug-serialize", action="store_true", help=argparse.SUPPRESS)
# This one is deprecated, but we will keep it for few releases.
parser.add_argument(
"--enable-incomplete-features", action="store_true", help=argparse.SUPPRESS
Expand Down
3 changes: 3 additions & 0 deletions mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def __init__(self) -> None:
# Read cache files in fine-grained incremental mode (cache must include dependencies)
self.use_fine_grained_cache = False

# Run tree.serialize() even if cache generation is disabled
self.debug_serialize = False

# Tune certain behaviors when being used as a front-end to mypyc. Set per-module
# in modules being compiled. Not in the config file or command line.
self.mypyc = False
Expand Down