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
{{ message }}
Repository navigation
NamedTuple no longer includes ellipsis for fields with default values #15638
In the past, stubgen would indicate NamedTuple fields with default values using an ellipsis. Now it does not indicate which fields have default values in any way. I don't know exactly what version I used to generate my old stubs, but it was about 2 years ago.
To Reproduce
Run stubgen on a python file containing the following
from typing import NamedTuple
class Spam(NamedTuple):
a: int
b: int = 1
Expected Behavior
The generated stub should look like
from typing import NamedTuple
class Spam(NamedTuple):
a: int
b: int = ...
Actual Behavior
The generated stub looks like
from typing import NamedTuple
class Spam(NamedTuple):
a: int
b: int
Your Environment
Mypy version used: 1.4.1
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Activity
sobolevn commentedon Jul 15, 2023
This was not specific for named tuples, it was a general logic for all class level assigns: https://github.com/python/mypy/blob/v0.750/mypy/stubgen.py#L981-L982
But, I agree that it makes the difference for named tuples:
[stubgen] Add required `...` rhs to `NamedTuple` fields with default …