Skip to content

Commit a399e1c

Browse files
Add install_types to OPTIONS_AFFECTING_CACHE (#21070)
Noticed in #21068 Invalidate the cache when `--install-types` changes so that previous runs without `--install-types` don't prevent stub packages from being installed. **Before** (note: no install attempt in second invocation) ```shell $ echo 'import pygments' > file.py $ python3 -m mypy ./file.py file.py:1: error: Library stubs not installed for "pygments.lexers" [import-untyped] file.py:1: note: Hint: "python3 -m pip install types-Pygments" file.py:1: note: (or run "mypy --install-types" to install all missing stub packages) file.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports file.py:1: error: Library stubs not installed for "pygments" [import-untyped] Found 2 errors in 1 file (checked 1 source file) $ python3 -m mypy --install-types --non-interactive ./file.py file.py:1: error: Library stubs not installed for "pygments.lexers" [import-untyped] file.py:1: note: Hint: "python3 -m pip install types-Pygments" file.py:1: note: (or run "mypy --install-types" to install all missing stub packages) file.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports file.py:1: error: Library stubs not installed for "pygments" [import-untyped] Found 2 errors in 1 file (checked 1 source file) ``` **After** (note: install in second invocation) ```shell $ echo 'import pygments' > file.py $ python3 -m mypy ./file.py file.py:1: error: Library stubs not installed for "pygments.lexers" [import-untyped] file.py:1: note: Hint: "python3 -m pip install types-Pygments" file.py:1: note: (or run "mypy --install-types" to install all missing stub packages) file.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports file.py:1: error: Library stubs not installed for "pygments" [import-untyped] Found 2 errors in 1 file (checked 1 source file) $ python3 -m mypy --install-types --non-interactive ./file.py Installing missing stub packages: [...]/.temp_venv/bin/python3 -m pip install types-Pygments Collecting types-Pygments Using cached types_pygments-2.19.0.20251121-py3-none-any.whl.metadata (2.0 kB) Requirement already satisfied: types-docutils in ./.temp_venv/lib/python3.13/site-packages (from types-Pygments) (0.22.3.20260322) Using cached types_pygments-2.19.0.20251121-py3-none-any.whl (25 kB) Installing collected packages: types-Pygments Successfully installed types-Pygments-2.19.0.20251121 [notice] A new release of pip is available: 25.3 -> 26.0.1 [notice] To update, run: pip install --upgrade pip Success: no issues found in 1 source file ```
1 parent f394946 commit a399e1c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mypy/options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class BuildType:
7878
"fixed_format_cache",
7979
"untyped_calls_exclude",
8080
"enable_incomplete_feature",
81+
"install_types",
8182
}
8283
) - {"debug_cache"}
8384

0 commit comments

Comments
 (0)