Skip to content
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
12 changes: 6 additions & 6 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,12 +1680,12 @@ def find_cache_meta(
if manager.plugins_snapshot != manager.old_plugins_snapshot:
manager.log(f"Metadata abandoned for {id}: plugins differ")
return None
# So that plugins can return data with tuples in it without
# things silently always invalidating modules, we round-trip
# the config data. This isn't beautiful.
plugin_data = json_loads(
json_dumps(manager.plugin.report_config_data(ReportConfigContext(id, path, is_check=True)))
)
plugin_data = manager.plugin.report_config_data(ReportConfigContext(id, path, is_check=True))
if not manager.options.fixed_format_cache:
# So that plugins can return data with tuples in it without
# things silently always invalidating modules, we round-trip
# the config data. This isn't beautiful.
plugin_data = json_loads(json_dumps(plugin_data))
if m.plugin_data != plugin_data:
manager.log(f"Metadata abandoned for {id}: plugin configuration differs")
return None
Expand Down
10 changes: 6 additions & 4 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,12 @@ def add_invertible_flag(
action="store_true",
help="Include fine-grained dependency information in the cache for the mypy daemon",
)
incremental_group.add_argument(
"--fixed-format-cache",
action="store_true",
help="Use new fast and compact fixed format cache",
add_invertible_flag(
"--no-fixed-format-cache",
dest="fixed_format_cache",
default=True,
help="Do not use new fixed format cache",
group=incremental_group,
)
incremental_group.add_argument(
"--skip-version-check",
Expand Down
2 changes: 1 addition & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def __init__(self) -> None:
self.incremental = True
self.cache_dir = defaults.CACHE_DIR
self.sqlite_cache = False
self.fixed_format_cache = False
self.fixed_format_cache = True
self.debug_cache = False
self.skip_version_check = False
self.skip_cache_mtime_checks = False
Expand Down
1 change: 0 additions & 1 deletion mypy_self_check.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ enable_error_code = ignore-without-code,redundant-expr
enable_incomplete_feature = PreciseTupleTypes
show_error_code_links = True
warn_unreachable = True
fixed_format_cache = True
2 changes: 1 addition & 1 deletion mypyc/codegen/emitmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def compile_ir_to_c(

def get_ir_cache_name(id: str, path: str, options: Options) -> str:
meta_path, _, _ = get_cache_names(id, path, options)
# Mypy uses JSON cache even with --fixed-format-cache (for now).
# Mypyc uses JSON cache even with --fixed-format-cache (for now).
return meta_path.replace(".meta.json", ".ir.json").replace(".meta.ff", ".ir.json")


Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ $ {python} -c "print('x=1')" >foo.py
$ {python} -c "print('x=1')" >bar.py
$ mypy --local-partial-types --cache-fine-grained --follow-imports=error --no-sqlite-cache --python-version=3.11 -- foo.py bar.py
Success: no issues found in 2 source files
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.11/bar.meta.json', 'asdf.json')"
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.11/bar.meta.ff', 'asdf.ff')"
-- update bar's timestamp but don't change the file
$ {python} -c "import time;time.sleep(1)"
$ {python} -c "print('x=1')" >bar.py
Expand All @@ -328,7 +328,7 @@ Daemon is up and running
$ dmypy stop
Daemon stopped
-- copy the original bar cache file back so that the mtime mismatches
$ {python} -c "import shutil; shutil.copy('asdf.json', '.mypy_cache/3.11/bar.meta.json')"
$ {python} -c "import shutil; shutil.copy('asdf.ff', '.mypy_cache/3.11/bar.meta.ff')"
-- sleep guarantees timestamp changes
$ {python} -c "import time;time.sleep(1)"
$ {python} -c "print('lol')" >foo.py
Expand All @@ -341,7 +341,7 @@ Found 1 error in 1 file (checked 2 source files)
$ {python} -c "import sys; sys.stdout.write(open('log').read())"
-- make sure the meta file didn't get updated. we use this as an imperfect proxy for
-- whether the source file got rehashed, which we don't want it to have been.
$ {python} -c "x = open('.mypy_cache/3.11/bar.meta.json').read(); y = open('asdf.json').read(); assert x == y"
$ {python} -c "x = open('.mypy_cache/3.11/bar.meta.ff', 'rb').read(); y = open('asdf.ff', 'rb').read(); assert x == y"

[case testDaemonSuggest]
$ dmypy start --log-file log.txt -- --follow-imports=error --no-error-summary
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/fine-grained-cache-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ x = 10
[file p/c.py]
class C: pass

[delete ../.mypy_cache/3.9/b.meta.json.2]
[delete ../.mypy_cache/3.9/p/c.meta.json.2]
[delete ../.mypy_cache/3.9/b.meta.ff.2]
[delete ../.mypy_cache/3.9/p/c.meta.ff.2]

[out]
==