Skip to content

Commit 1be60fe

Browse files
authored
Flip fixed-format cache to on by default (#20758)
Since this is scheduled for v1.20 it is better do this sooner than later. So that people who are using mypy master can give some early feedback.
1 parent 1d18566 commit 1be60fe

7 files changed

Lines changed: 19 additions & 18 deletions

File tree

mypy/build.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,12 +1680,12 @@ def find_cache_meta(
16801680
if manager.plugins_snapshot != manager.old_plugins_snapshot:
16811681
manager.log(f"Metadata abandoned for {id}: plugins differ")
16821682
return None
1683-
# So that plugins can return data with tuples in it without
1684-
# things silently always invalidating modules, we round-trip
1685-
# the config data. This isn't beautiful.
1686-
plugin_data = json_loads(
1687-
json_dumps(manager.plugin.report_config_data(ReportConfigContext(id, path, is_check=True)))
1688-
)
1683+
plugin_data = manager.plugin.report_config_data(ReportConfigContext(id, path, is_check=True))
1684+
if not manager.options.fixed_format_cache:
1685+
# So that plugins can return data with tuples in it without
1686+
# things silently always invalidating modules, we round-trip
1687+
# the config data. This isn't beautiful.
1688+
plugin_data = json_loads(json_dumps(plugin_data))
16891689
if m.plugin_data != plugin_data:
16901690
manager.log(f"Metadata abandoned for {id}: plugin configuration differs")
16911691
return None

mypy/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,10 +1076,12 @@ def add_invertible_flag(
10761076
action="store_true",
10771077
help="Include fine-grained dependency information in the cache for the mypy daemon",
10781078
)
1079-
incremental_group.add_argument(
1080-
"--fixed-format-cache",
1081-
action="store_true",
1082-
help="Use new fast and compact fixed format cache",
1079+
add_invertible_flag(
1080+
"--no-fixed-format-cache",
1081+
dest="fixed_format_cache",
1082+
default=True,
1083+
help="Do not use new fixed format cache",
1084+
group=incremental_group,
10831085
)
10841086
incremental_group.add_argument(
10851087
"--skip-version-check",

mypy/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def __init__(self) -> None:
292292
self.incremental = True
293293
self.cache_dir = defaults.CACHE_DIR
294294
self.sqlite_cache = False
295-
self.fixed_format_cache = False
295+
self.fixed_format_cache = True
296296
self.debug_cache = False
297297
self.skip_version_check = False
298298
self.skip_cache_mtime_checks = False

mypy_self_check.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ enable_error_code = ignore-without-code,redundant-expr
1313
enable_incomplete_feature = PreciseTupleTypes
1414
show_error_code_links = True
1515
warn_unreachable = True
16-
fixed_format_cache = True

mypyc/codegen/emitmodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def compile_ir_to_c(
355355

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

361361

test-data/unit/daemon.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ $ {python} -c "print('x=1')" >foo.py
316316
$ {python} -c "print('x=1')" >bar.py
317317
$ mypy --local-partial-types --cache-fine-grained --follow-imports=error --no-sqlite-cache --python-version=3.11 -- foo.py bar.py
318318
Success: no issues found in 2 source files
319-
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.11/bar.meta.json', 'asdf.json')"
319+
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.11/bar.meta.ff', 'asdf.ff')"
320320
-- update bar's timestamp but don't change the file
321321
$ {python} -c "import time;time.sleep(1)"
322322
$ {python} -c "print('x=1')" >bar.py
@@ -328,7 +328,7 @@ Daemon is up and running
328328
$ dmypy stop
329329
Daemon stopped
330330
-- copy the original bar cache file back so that the mtime mismatches
331-
$ {python} -c "import shutil; shutil.copy('asdf.json', '.mypy_cache/3.11/bar.meta.json')"
331+
$ {python} -c "import shutil; shutil.copy('asdf.ff', '.mypy_cache/3.11/bar.meta.ff')"
332332
-- sleep guarantees timestamp changes
333333
$ {python} -c "import time;time.sleep(1)"
334334
$ {python} -c "print('lol')" >foo.py
@@ -341,7 +341,7 @@ Found 1 error in 1 file (checked 2 source files)
341341
$ {python} -c "import sys; sys.stdout.write(open('log').read())"
342342
-- make sure the meta file didn't get updated. we use this as an imperfect proxy for
343343
-- whether the source file got rehashed, which we don't want it to have been.
344-
$ {python} -c "x = open('.mypy_cache/3.11/bar.meta.json').read(); y = open('asdf.json').read(); assert x == y"
344+
$ {python} -c "x = open('.mypy_cache/3.11/bar.meta.ff', 'rb').read(); y = open('asdf.ff', 'rb').read(); assert x == y"
345345

346346
[case testDaemonSuggest]
347347
$ dmypy start --log-file log.txt -- --follow-imports=error --no-error-summary

test-data/unit/fine-grained-cache-incremental.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ x = 10
234234
[file p/c.py]
235235
class C: pass
236236

237-
[delete ../.mypy_cache/3.9/b.meta.json.2]
238-
[delete ../.mypy_cache/3.9/p/c.meta.json.2]
237+
[delete ../.mypy_cache/3.9/b.meta.ff.2]
238+
[delete ../.mypy_cache/3.9/p/c.meta.ff.2]
239239

240240
[out]
241241
==

0 commit comments

Comments
 (0)