]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: avoid using SQLite cache in Mypy runs master
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 1 Apr 2026 10:55:24 +0000 (12:55 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 1 Apr 2026 16:04:29 +0000 (18:04 +0200)
Since Mypy 1.20 the SQLite cache is used by default. This highlights
Mypy concurrency issues running pre-commit in the CI, which are known to
the project devs but which we practically never encountered using the
file-based cache. See https://github.com/python/mypy/issues/21136.

The alternative solution of avoiding parallel Mypy runs in pre-commit
using `require_serial: false`, reveals other issues such as
https://github.com/python/mypy/issues/17362.

An alternative which would probably work could be to pass no file names
to mypy and re-mypy the entire codebase at every commit using
`pass_filenames: false`. See https://github.com/python/mypy/issues/13916.
This for me seems about 25% slower when changing a single file.

This commit restores the 1.19 behaviour of using the file-based cache,
which was working adequately for us. In the future we may decide to move
to `pass_filenames: false`.

pyproject.toml

index 9b7acfafca22ed9912c6933a7834dfbe43a26ed5..dcf825878bc59d81caa9b50f3cc7f517ba671b83 100644 (file)
@@ -42,6 +42,16 @@ exclude = '''(?x)(
     | tests/test_tstring\.py
 )'''
 
+# Don't use SQLite cache as it highlights Mypy concurrency issues.
+# See https://github.com/python/mypy/issues/21136
+# The issue is triggered by parallel mypy runs under pre-commit, setting
+# the parameter here allows the use of the same cache both by pre-commit and
+# every other Mypy usage.
+#
+# Check https://github.com/python/mypy/issues/13916 in the future to see
+# if new ways to run mypy under pre-commit emerge.
+sqlite_cache = false
+
 [[tool.mypy.overrides]]
 module = [
     "numpy.*",