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
When running stubgen on a file that uses TypeAlias, the stubbed type of the type alias is TypeAlias. This prevents the actual aliased type from being recorded in the stub file, and causes mypy to emit a [valid-type] error.
I'm not exactly sure what the expected behavior is. I guess maybe it should behave similarly to Foo = tuple[int, str] (i.e. without the TypeAlias typehint), which stubgen includes verbatim in the stub file.
Actual Behavior
The stubbed type was only TypeAlias
$ cat out/tmp.pyi
from typing import TypeAlias
Foo: TypeAlias
Then if this stub is used, mypy emits the following error:
Invalid type alias: expression is not a valid type [valid-type]
Foo: TypeAlias
^
Your Environment
Mypy version used: 1.15.0
Mypy command-line flags: n/a
Mypy configuration options from mypy.ini (and other config files): n/a
Python version used: 3.10
The text was updated successfully, but these errors were encountered:
Bug Report
When running stubgen on a file that uses
TypeAlias
, the stubbed type of the type alias isTypeAlias
. This prevents the actual aliased type from being recorded in the stub file, and causes mypy to emit a[valid-type]
error.To Reproduce
Create a file
tmp.py
:Then run
stubgen tmp.py
.Expected Behavior
I'm not exactly sure what the expected behavior is. I guess maybe it should behave similarly to
Foo = tuple[int, str]
(i.e. without theTypeAlias
typehint), which stubgen includes verbatim in the stub file.Actual Behavior
The stubbed type was only
TypeAlias
Then if this stub is used, mypy emits the following error:
Your Environment
mypy.ini
(and other config files): n/aThe text was updated successfully, but these errors were encountered: