-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[red-knot] Understanding type[Union[A, B]]
#14858
Conversation
The failing test boils down to this: import collections
MyObj1 = collections.namedtuple("MyObj1", ["a", "b"]) |
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.
The tests are failing with a panic in an assertion. Would you mind taking a look at what's happening
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.
Thanks. There were a couple of issues with your initial patch; I've pushed to your branch to fix them:
- You didn't handle single-element unions such as
type[Union[int]]
(the subscript slice inside theUnion[]
is not anExpr::Tuple
if there's only a single element). - You were failing to store the types of subexpressions for subscripts that are either invalid or not-yet-supported; that was causing panics in the corpus test. It can be surprisingly tricky to make sure that you infer the type of each subexpression exactly once; it took me longer than I expected to fix this!
- Going forward, we'd prefer to use parameter annotations in mdtests to test type expressions rather than return annotations, as they're more concise ([red-knot] Improve the style of various mdtests #14839)
|
@AlexWaygood Thanks! |
Summary
Resolves #14834.
Test Plan
Markdown tests.