[stubgen] Add required ... rhs to NamedTuple fields with default values#15680
Merged
[stubgen] Add required ... rhs to NamedTuple fields with default values#15680
... rhs to NamedTuple fields with default values#15680Conversation
... rhs to NamedTuple fields with default values... rhs to NamedTuple fields with default values
sobolevn
commented
Jul 23, 2023
Member
Author
There was a problem hiding this comment.
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: strTwo changes in tests:
= ...is missingclass Nested: ...is present
What is going on? :)
Member
Author
|
Ok, I need |
Member
Author
|
I've created a new issue about nested classes in |
AlexWaygood
reviewed
Jul 28, 2023
AlexWaygood
approved these changes
Jul 28, 2023
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
LGTM other than my nit about the test
AlexWaygood
approved these changes
Jul 28, 2023
sobolevn
added a commit
that referenced
this pull request
Jul 29, 2023
This is a test case for #15680 from `stubtest`'s point of view.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15638