[stubgen] Add required ...
rhs to NamedTuple
fields with default values by sobolevn · Pull Request #15680 · python/mypy (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After your review, I've noticed that the test case is broken. I was testing it locally with stubgen ex.py && bat out/ex.pyi
and it all worked correctly.
For example, stubgen
for this file:
ex.py
from typing import NamedTuple
class A(NamedTuple): x: int y: str = 'a'
class B(A): z1: str z2 = 1
class RegularClass: x: int y: str = 'a' class NestedNamedTuple(NamedTuple): x: int y: str = 'a'
class NamedTupleWithNestedClass(NamedTuple): class Nested: x: int y: str = 'a'
Produces the following .pyi
file:
from typing import NamedTuple
class A(NamedTuple): x: int y: str = ...
class B(A): z1: str z2: int
class RegularClass: x: int y: str class NestedNamedTuple(NamedTuple): x: int y: str = ...
class NamedTupleWithNestedClass(NamedTuple): ...
But, here's what is produced with our test case:
from typing import NamedTuple
class A(NamedTuple): x: int y: str
class B(A):
z1: str
z2: int
class RegularClass: x: int y: str class NestedNamedTuple(NamedTuple): x: int y: str
class NamedTupleWithNestedClass(NamedTuple): class Nested: x: int y: str
Two changes in tests:
= ...
is missingclass Nested: ...
is present
What is going on? :)