You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ mypy b.py
b.py:8: error: TypedDict "a.Dict[TValue]" has no key "x" [typeddict-item]
Found 1 error in 1 file (checked 1 source file)
as expected.
However, running mypy b.pya second time reports an extra [type-arg] and a few more related errors as well,
$ mypy b.py
b.py:3: error: "Dict" expects no type arguments, but 1 given [type-arg]
b.py:3: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
b.py:4: error: Incompatible return value type (got "TValue", expected "TValue") [return-value]
b.py:7: error: "Dict" expects no type arguments, but 1 given [type-arg]
b.py:7: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
b.py:8: error: TypedDict "a.Dict[TValue]" has no key "x" [typeddict-item]
Found 6 errors in 1 file (checked 1 source file)
from then on, the only way to get rid of the [type-arg] error is to run with --no-increment or delete the cache. Here, I removed g(), leaving
$ mypy b.py
b.py:3: error: "Dict" expects no type arguments, but 1 given [type-arg]
b.py:3: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
b.py:4: error: Incompatible return value type (got "TValue", expected "TValue") [return-value]
Found 3 errors in 1 file (checked 1 source file)
but
$ mypy --no-increment b.py
Success: no issues found in 1 source file
Expected Behavior
No difference between mypy, mypy --no-increment and the generic TypedDict do not corrupt the cache.
Actual Behavior
mypy reports false positives
b.py:3: error: "Dict" expects no type arguments, but 1 given [type-arg]
b.py:3: error: A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]
b.py:4: error: Incompatible return value type (got "TValue", expected "TValue") [return-value]
Your Environment
Mypy version used: 0.991, 1.0.0, master
Mypy command-line flags: mypy vs. mypy --no-increment
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.11 or importing TypedDict from mypy_extensions on Python 3.10.
I could also reproduce that under Linux (Ubuntu 22.04) and MacOS (M1---Python installed via MacPorts).
The text was updated successfully, but these errors were encountered:
Fixes#14638
TBH I don't remember why do we need to create the "incomplete" type
alias (with empty type variables), and set up type variables later. But
I didn't want to risk a larger refactoring and just fixed the missing
calls surfaced by the issue instead.
ilinum
pushed a commit
to ilinum/mypy
that referenced
this issue
Feb 14, 2023
Fixespython#14638
TBH I don't remember why do we need to create the "incomplete" type
alias (with empty type variables), and set up type variables later. But
I didn't want to risk a larger refactoring and just fixed the missing
calls surfaced by the issue instead.
CheckmkCI
pushed a commit
to Checkmk/checkmk
that referenced
this issue
Feb 23, 2023
Bug Report
Using a generic
TypedDict
in another module may corrupt the cache. The cache doesn't recover and must be deleted.To Reproduce
In module
a
, define a genericTypedDict
,in another module (say
b
) use this definition. The easiest way to trigger the bug is to have at least one typing error in the file (hereg()
).Now, type check
b
as expected.
However, running
mypy b.py
a second time reports an extra[type-arg]
and a few more related errors as well,from then on, the only way to get rid of the
[type-arg]
error is to run with--no-increment
or delete the cache. Here, I removedg()
, leavingand
but
Expected Behavior
No difference between
mypy
,mypy --no-increment
and the genericTypedDict
do not corrupt the cache.Actual Behavior
mypy reports false positives
Your Environment
mypy
vs.mypy --no-increment
mypy.ini
(and other config files): noneTypedDict
frommypy_extensions
on Python 3.10.I could also reproduce that under Linux (Ubuntu 22.04) and MacOS (M1---Python installed via MacPorts).
The text was updated successfully, but these errors were encountered: