-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ty] Implement disjointness for TypedDicts #22044
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
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
| # TODO: T can't be compatible with both `int` and `bool` at the same time, so these types should be | ||
| # disjoint, regardless of the materialization of `T`. |
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.
Is this sort of "one dynamic type winds up in multiple fields" situation ever something we reason about? Is there a name for this?
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.
hmm, yeah, this is pretty interesting. No, I haven't come across this problem before, but thinking about it, it must exist for other generic types in our model too. I wouldn't worry about it too much right now, but it could be worth opening a followup issue to discuss it.
|
CodSpeed Performance ReportMerging #22044 will improve performances by 70.52%Comparing Summary
Benchmarks breakdown
Footnotes
|
Clippy and Cargo want very different things here. Clippy demands that the numbered list is indented, but that makes Cargo think it's Rust code and start trying to compile it. I don't know how to make them both happy, so I'm making it a regular `//` comment block instead of an actual `///` doc comment, which seems to shut them both up...
TypedDictType::is_disjoint_from_impl
AlexWaygood
left a comment
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.
This looks great!! Really good job
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.
Fantastic test suite!
| # TODO: T can't be compatible with both `int` and `bool` at the same time, so these types should be | ||
| # disjoint, regardless of the materialization of `T`. |
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.
hmm, yeah, this is pretty interesting. No, I haven't come across this problem before, but thinking about it, it must exist for other generic types in our model too. I wouldn't worry about it too much right now, but it could be worth opening a followup issue to discuss it.
| // 2c. If both sides are immutable, and their types are disjoint. (Because the type in `C` | ||
| // must be assignable to both.) | ||
| // | ||
| // TODO: Adding support for `closed` and `extra_items` will complicate this. |
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.
🙃
|
This mypy_primer hit is in fact a new false positive: + openlibrary/plugins/openlibrary/lists.py:89:19: error[invalid-key] Unknown key "key" for TypedDict `AnnotatedSeedDict`: Unknown key "key"Previously the type of Edit: This is mistaken, see the next comment. |
|
Hmm, actually my comment above is mistaken. |
This is a preliminary step to tagged union narrowing for
TypedDict: astral-sh/ty#1479