Skip to content

Flag --enable-incomplete-feature only takes effect after clearing .mypy_cache manually #20845

@Dutcho

Description

@Dutcho

Bug Report
MyPy doesn't refresh its cache when invoked with (some?) flags (--enable-incomplete-feature; haven't tested others) that were not present on previous command line.
To Reproduce
If I typetest a minimal snippet:

from typing_extensions import TypeForm
def test[TF](tf: TypeForm[TF]) -> None: ...

MyPy complains:

>mypy snippet.py
snippet.py:2: error: TypeForm is experimental, must be enabled with --enable-incomplete-feature=TypeForm  [misc]
Found 1 error in 1 file (checked 1 source file)

Following MyPy's suggestion initially doesn't help:

>mypy --enable-incomplete-feature=TypeForm snippet.py
snippet.py:2: error: TypeForm is experimental, must be enabled with --enable-incomplete-feature=TypeForm  [misc]
Found 1 error in 1 file (checked 1 source file)

Only if I forcefully refresh the cache (by deleting it as below, or by type-checking against a different --python-version), the flag takes effect:

>rmdir /s .mypy_cache
.mypy_cache, Are you sure (Y/N)? y
>mypy --enable-incomplete-feature=TypeForm snippet.py
Success: no issues found in 1 source file

Expected Behavior
I expected MyPy to invalidate the cache when invoked with the suggested --enable-incomplete-feature (like it apparently does for --python-version). Or, at least, to mention in the suggestion the need to do so manually.
Actual Behavior
But MyPy relied on its cache, which presumably contains its analysis results without --enable-incomplete-feature. And its suggestion didn't reference the cache, so I found out only after perplexedly trying a different --python-version to see whether that helped (yes :-).
Severity
It's a minor inconvenience to need to clear the cache. But it's far from obvious (at least to me) that such clearing is needed.
If not fixed, that's fine but then a note in MyPy's suggestion would be most welcome.
Your Environment

  • Mypy version used: 1.19.1 from PyPI
  • Mypy command-line flags: first without, and then with --enable-incomplete-feature=TypeForm
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.15.0a6, 3.14.3, 3.13.12 on Windows 11

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions