-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ty] chore: ContextManagerError
message update
#20199
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
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
06686e9
to
0fdf81e
Compare
ContextManagerError
message update
0fdf81e
to
9733d41
Compare
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 for the pull request! This is definitely an improvement.
My idea when I filed the issue was that we would bubble up the information about which types had the dunder unbound or possibly-unbound as part of the CallDunderError
, but looking at it now I see this would probably require special-casing Type::Union
in try_call_dunder
(because member_lookup_with_policy
squashes union information into a single PlaceAndQualifiers
). I still think this might make sense, but I also think it's OK to just re-create the information once we know there's a problem.
@@ -84,6 +84,117 @@ async def main(): | |||
... | |||
``` | |||
|
|||
## Union context managers with specific member issues | |||
|
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.
We can snapshot diagnostics for these tests, which is an easier way to see the full resulting diagnostic, instead of putting full error messages directly in the mdtest. This is usually preferred for tests focused on diagnostic rendering, and is especially useful when the diagnostic is not all crammed into a single sentence, as I suggest below.
<!-- snapshot-diagnostics --> | |
Then you use cargo insta test -p ty_python_semantic
to generate new snapshots to review with cargo insta review
and then commit.
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.
Sorry for the rookie question.
Can I get a really brief example of how snapshots work?
e.g. should be snapshotted in main or post changes? What if the message changes do I need to update snaps? Are all the snaps run when I do cargo nextest run
?
|
||
context_expr = Bound() if flag else EnterUnbound() | ||
|
||
# error: [invalid-context-manager] "Object of type `Bound | EnterUnbound` cannot be used with `async with` because the method `__aenter__` of `EnterUnbound` is possibly unbound" |
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.
E.g. if we snapshot diagnostics, then we can just do this here:
# error: [invalid-context-manager] "Object of type `Bound | EnterUnbound` cannot be used with `async with` because the method `__aenter__` of `EnterUnbound` is possibly unbound" | |
# error: [invalid-context-manager] |
Thank you for your review @carljm! I'm quite rookie with Rust and I'll read each suggestion carefully and work on a new approach, will ping you once it's ready. Thanks! |
@Y3K happy to offer clarification on any comments. I think for purposes of this PR you can ignore the comment about "bubbling up the information through |
Thank you again, @carljm ! I don't want to waste a lot of your time, but I do accept any extra help you want and can provide. Will address all your feedback within this PR 🙌🏼 |
aee5519
to
67846c0
Compare
Summary
Fixes astral-sh/ty#940
Test Plan