-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Bug Report
Stubgen generates an output file with a syntax error.
It generates def __mypy-replace
which is invalid python syntax because of the dash.
To Reproduce
With the following python code, generate a stub including the --include-private
flag.
stubgen --include-private test.py
from dataclasses import dataclass
@dataclass
class MyDataClass:
foo: str
bar: int
Expected Behavior
The stub is generated without syntax errors.
Actual Behavior
A syntax error is raised when parsing the file:
File "out/test.pyi", line 5
def __mypy-replace(*, foo, bar) -> None: ...
^
SyntaxError: invalid syntax
When I generate the file without --include-private
than the stub is generated correctly.
Your Environment
- Mypy version used: 1.5.1
- Python version used: 3.11.4
Extra info
Also see KapJI/homeassistant-stubs#349 where this issue was raised.
These stubs are used in custom Home Assistant components, and currently this is broken.
ogajduse and KapJI