[ty] Improve type context support for __setitem__ dunder calls#23800
Merged
ibraheemdev merged 1 commit intomainfrom Mar 10, 2026
Merged
[ty] Improve type context support for __setitem__ dunder calls#23800ibraheemdev merged 1 commit intomainfrom
__setitem__ dunder calls#23800ibraheemdev merged 1 commit intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 85.05%. The percentage of expected errors that received a diagnostic held steady at 78.05%. The number of fully passing files held steady at 63/132. |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
sphinx
trio
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
40 | 0 | 0 |
invalid-assignment |
0 | 10 | 2 |
invalid-return-type |
1 | 0 | 0 |
| Total | 41 | 10 | 2 |
Member
|
I'm happy to review this one. |
|
|
||
| // Perform the first attempt without type context, ignoring the inferred type. | ||
| infer_slice_ty(self, TypeContext::default()); | ||
| infer_rhs_value(self, TypeContext::default()); |
Member
There was a problem hiding this comment.
Can you explain this piece?
Member
Author
There was a problem hiding this comment.
I cleaned this up a bit, the basic idea is that we should only ever produce diagnostics for a given expression once, and so later multi-inference attempts silence diagnostics, and are only used for assignability checks.
f58444a to
b1bbf63
Compare
b1bbf63 to
9754f6a
Compare
ibraheemdev
commented
Mar 9, 2026
| ); | ||
|
|
||
| if !valid && emit_diagnostic_and_short_circuit { | ||
| if valid || emit_diagnostic_and_short_circuit { |
Member
Author
There was a problem hiding this comment.
We previously weren't short-circuiting here if we found an assignable element, not sure why.
charliermarsh
approved these changes
Mar 9, 2026
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.
Resolves astral-sh/ty#2986. I also ended up refactoring some things here, see astral-sh/ty#3001 for details.