Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
trio
flake8
sphinx
|
5ea60a4 to
46e2ac6
Compare
|
08b555a to
8ed8742
Compare
4e45934 to
ca9e7f6
Compare
Member
|
@lerebear we use the assignee field to track who's responsible for reviewing a PR based on a round robin selection. For this to work, the Assignees field must be empty when marking a PR ready for review. You're obviously always allowed to manually change the assignee if you think someone else is a better fit. |
Member
charliermarsh
left a comment
There was a problem hiding this comment.
Just two questions. The Rust here looks good!
74afaf5 to
a77845f
Compare
Contributor
Author
Thanks for the review @charliermarsh! I addressed both points, so this should be ready for a fresh review please. |
a77845f to
3f40b1a
Compare
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.
Summary
As part of astral-sh/ty#940, this helps us emit more specific diagnostics for possibly unbound context manager dunders (e.g.,
__enter__,__exit__) invoked on a union type.Where previously the following snippet would produce just the top-level diagnostic commented below:
We will now produce two further "info" sub-diagnostics:
Approach
This implements the approach suggested by
@carljmhere from a previous attempt to address improve diagnostics for possibly-unbound call-dunder with union ty#940; it extendsCallDunderError::PossiblyUnboundwith a newunbound_onfield that stores a list of the union members on which a particular dunder is unbound. We create the new, richer error with a newUnionType.try_call_dunder_with_policymethod that looks up the dunder on each member of the union, and then aggregates the results. This is supersedes the previousUnionType.map_with_boundness_and_qualifiersapproach, and allows us to preserve the per-member binding information that we use to produce the more detailed diagnostic.There are two alternatives to this approach that I considered but rejected:
ContextManagerErrormessage update #20199, but I think it will lead to some unnecessary code duplication across callsites (of which there are at least three more).UnionType.map_with_boundness_and_qualifierssuch that it no longer loses member-specific binding information when producing its result. This would have required an extension toPlaceAndQualifiers, which would have a large blast radius and also introduce overhead in several cases where member-specific information for unions is not necessary.There are more implicit dunder calls that can benefit from the new shape of
CallDunderError::PossiblyUnbound, but I have intentionally deferred those to a follow-up in order to first collect feedback on a more targeted changeset.The first three commits in this PR (926bcec, 65dc3fb, 988e81d) are "prefactors" that do not change any observable behaviour. The fourth (2422844) actually implements the improvement, and deserves the most scrutiny.
Test Plan
Please see updated mdtests and associated snapshots.