-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
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
[stubgen] Add required ...
rhs to NamedTuple
fields with default values
#15680
Conversation
...
rhs to NamedTuple
fields with default values...
rhs to NamedTuple
fields with default values
There was a problem hiding this comment.
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? :)
Ok, I need |
I've created a new issue about nested classes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM other than my nit about the test
This is a test case for #15680 from `stubtest`'s point of view.
Closes #15638