[ty] Add panic-by-default await methods to TestServer#21451
[ty] Add panic-by-default await methods to TestServer#21451MichaReiser merged 2 commits intomainfrom
TestServer#21451Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
70f6a11 to
37f4080
Compare
dhruvmanila
left a comment
There was a problem hiding this comment.
This sounds reasonable to me, I only have a few minor comments which doesn't necessarily need to be addressed.
crates/ty_server/tests/e2e/main.rs
Outdated
| Err(err) => match err { | ||
| TestServerError::ResponseError(response_error) => { |
There was a problem hiding this comment.
Should we use the thiserror::Error messages here to display the error here? We could possibly add the request ID as context.
crates/ty_server/tests/e2e/main.rs
Outdated
| Err(err) => match err { | ||
| TestServerError::RecvTimeoutError(RecvTimeoutError::Disconnected) => { |
There was a problem hiding this comment.
Same here although this is a bit different but the response error variant could be moved first to use unreachable and then a catch-all err for the remaining error.
crates/ty_server/tests/e2e/main.rs
Outdated
| Err(err) => match err { | ||
| TestServerError::RecvTimeoutError(RecvTimeoutError::Disconnected) => { |
There was a problem hiding this comment.
Same here as the await_response comment.
|
I believe the return type for all of the test cases can now be removed (it is |
Unfortunately not. |
c0abee1 to
1523b8d
Compare
1523b8d to
6e4b15b
Compare
|
* origin/main: (59 commits) [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461) [ty] Improve literal promotion heuristics (#21439) [ty] Further improve details around which expressions should be deferred in stub files (#21456) [ty] Improve generic class constructor inference (#21442) [ty] Propagate type context through conditional expressions (#21443) [ty] Suppress completions when introducing names with `as` [ty] Add panic-by-default await methods to `TestServer` (#21451) [ty] name is parameter and global is a syntax error (#21312) [ty] Fixup a few details around version-specific dataclass features (#21453) [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449) [ty] Support stringified annotations in value-position `Annotated` instances (#21447) [ty] Type inference for genererator expressions (#21437) [ty] Make `__getattr__` available for `ModuleType` instances (#21450) [ty] Increase default receive timeout in tests to 10s (#21448) [ty] Add synthetic members to completions on dataclasses (#21446) [ty] Support legacy `typing` special forms in implicit type aliases (#21433) Bump 0.14.5 (#21435) [ty] Support `type[…]` and `Type[…]` in implicit type aliases (#21421) [ty] Respect notebook cell boundaries when adding an auto import (#21322) Update PyCharm setup instructions (#21409) ...
* dcreager/deep-comparison: (64 commits) assuming SubtypingAssuming implies_subtype_of name tweak Apply suggestions from code review [ty] Improve diagnostic range for `non-subscriptable` diagnostics (#21461) [ty] Improve literal promotion heuristics (#21439) [ty] Further improve details around which expressions should be deferred in stub files (#21456) [ty] Improve generic class constructor inference (#21442) [ty] Propagate type context through conditional expressions (#21443) [ty] Suppress completions when introducing names with `as` [ty] Add panic-by-default await methods to `TestServer` (#21451) [ty] name is parameter and global is a syntax error (#21312) [ty] Fixup a few details around version-specific dataclass features (#21453) [ty] Support attribute-expression `TYPE_CHECKING` conditionals (#21449) [ty] Support stringified annotations in value-position `Annotated` instances (#21447) [ty] Type inference for genererator expressions (#21437) [ty] Make `__getattr__` available for `ModuleType` instances (#21450) [ty] Increase default receive timeout in tests to 10s (#21448) [ty] Add synthetic members to completions on dataclasses (#21446) ...
Summary
This should help with astral-sh/ty#1551. It doesn't
fix the root cause but I think it's an overall improvement to the testing experience.
The
await_response,await_notificationandawait_requestall return aResulttodayto account for that they can fail. However, almost all writen E2E tests only care about the
case where a request is successful.
This PR changes the
await_methods to panic by default when they fail and addstry_counterparts that return aResultinstead for the few cases where weexplicitly test the error case.
I find that this overall gives better ercognomis as we get a panic
on the line where the request failed rather than a: Test failed because request timed out
and you then have to guess which request it was.
Test Plan
cargo test