We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Report
The stubgen command generates an interface with invalid syntax for a data class that inherits from another class located in a different file.
stubgen
To Reproduce
>=3.7
mypy==0.941
python3.9 -m venv venv source venv/bin/activate pip install -U pip pip install mypy==0.941
a.py
class A: pass
b.py
from dataclasses import dataclass from a import A @dataclass class B(A): c: str
stubgen b.py -o .
python b.pyi
The generated b.pyi file has the following content:
b.pyi
from a import A class B(A): c: str def __init__(self, *, c, **) -> None: ...
Notes:
@dataclass
A
B
Expected Behavior
The generated b.pyi file has valid Python syntax and the python command executes without errors.
python
Actual Behavior
The generated b.pyi file doesn't have valid Python syntax and the command python b.pyi produces the following error:
File "/path/to/sandbox/b.pyi", line 5 def __init__(self, *, c, **) -> None: ... ^ SyntaxError: invalid syntax
Your Environment
0.941
0.940
0.931
-o
mypy.ini
3.9.0
3.7.12
3.8.5
3.10.0
3.6.9
Ubuntu 20.04.3 LTS
macOS Big Sur 11.5.2
pip list
$ pip list Package Version ----------------- ------- mypy 0.941 mypy-extensions 0.4.3 pip 22.0.4 setuptools 49.2.1 tomli 2.0.1 typing_extensions 4.1.1
The text was updated successfully, but these errors were encountered:
@hauntsaninja maybe you can fix this one as well? It's a bummer stubgen produces files with invalid syntax.
Sorry, something went wrong.
stubgen: generate valid dataclass stubs
faae3c0
Fixes python#12441
stubgen: generate valid dataclass stubs (#15625)
2bbc42f
Fixes #12441 Fixes #9986 Fixes #15966
Successfully merging a pull request may close this issue.
Bug Report
The
stubgen
command generates an interface with invalid syntax for a data class that inherits from another class located in a different file.To Reproduce
>=3.7
and installmypy==0.941
:python3.9 -m venv venv source venv/bin/activate pip install -U pip pip install mypy==0.941
a.py
with the following content:b.py
in the same directory with the following content:stubgen b.py -o .
python b.pyi
The generated
b.pyi
file has the following content:Notes:
@dataclass
.A
is in the same file.B
doesn't inherit fromA
.Expected Behavior
The generated
b.pyi
file has valid Python syntax and thepython
command executes without errors.Actual Behavior
The generated
b.pyi
file doesn't have valid Python syntax and the commandpython b.pyi
produces the following error:Your Environment
0.941
. Reproducible with0.940
as well. Cannot reproduce with0.931
.-o
mypy.ini
(and other config files): None3.9.0
. Also reproduced with3.7.12
,3.8.5
and3.10.0
. Cannot reproduce with3.6.9
.Ubuntu 20.04.3 LTS
. Also reproduced withmacOS Big Sur 11.5.2
pip list
output for Python 3.9.0:The text was updated successfully, but these errors were encountered: