-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] Add ty.experimental.rename server setting
#19800
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 ✅ |
|
MichaReiser
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.
I think it's safe to assume that clients that don't support dynamic registration probably also don't support the configuration request.
Should we register the rename provider for those statically if the experimental rename feature is enabled in the initialization options? We should probably do the same for workspace diagnsotics unless we're already doing this.
| self.register_diagnostic_capability(client); | ||
| self.register_rename_capability(client); |
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 isn't incorrect but the LSP supports sending multiple registrations in a single request. Should we change the regsiter_* to a register_dynamic_capability method that registers all dynamic capabilities (collects the one it must remove and then collects the one it needs to add)
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.
Yeah, I wanted to do something like that but the difference here is that for the rename capability we do want to unregister the capability but then we should avoid re-registering the capability. This scenario is only valid when we support didChangeConfiguration but I don't want to make any assumptions that might be incorrect later on.
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.
Oh, I could have two separate methods unregister_dynamic_capability and register_dynamic_capability which would solve 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.
I'm going to do this as a follow-up.
I'm not sure if we can assume that as dynamic registrations are scoped to individual capabilities and workspace configuration is an independent capability. So, a client might have dynamic registration for one capability while it might not for another. For workspace diagnostics, the server checks whether dynamic registration is supported. If not, it will statically register for the diagnostic capability during initialization but without looking at the We could do the same for the rename capability which is that we would check whether dynamic registration is supported for the rename capability and if it's not supported, statically register it during initialization. We could then check in the rename request handler whether the user has enabled this or not and return early if not. Does this make sense? |
I didn't see a meaningful value that the client could return in that case. That's why I suspect the best second solution is to only register the provider if the settings (resolved at this point) also enable it. It seems a better experience than one where users can't opt into the setting at all. |
Ok, so are you saying that the server would check the resolved initialization options and check whether the client supports dynamic registration for the relevant capability (rename and diagnostic) and set the server capability according the relevant server setting ( |
| } else { | ||
| // Otherwise, we check whether user has enabled rename support via the resolved settings | ||
| // from initialization options. | ||
| global_settings | ||
| .is_rename_enabled() | ||
| .then(|| OneOf::Right(server_rename_options())) | ||
| }; | ||
|
|
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 is the behavior that was discussed in the review feedback.
## Summary This is a complementary PR to astral-sh/ruff#19800 that adds the `ty.experimental.rename` setting in the extension. ## Test Plan Refer to the test plan in the PR.
## Summary This PR adds reference documentation for the two new editor settings that were added in astral-sh/ruff#19800 and astral-sh/ruff#19780. ## Test Plan <img width="2491" height="1374" alt="Screenshot 2025-08-07 at 19 24 44" src="https://github.com/user-attachments/assets/f0fc32c5-1045-4fd9-900d-c4e7e429d54f" />
* dcreager/bound-typevar: (24 commits) more comment fix this isn't true anymore fix inner function in overload implementation ecosystem error Update Rust toolchain to 1.89 (#19807) [ty] Add `ty.inlayHints.variableTypes` server option (#19780) synthetic typevars for type materializations are bound [ty] Add failing tests for tuple subclasses (#19803) [ty] Add `ty.experimental.rename` server setting (#19800) clippy make BoundTypeVarInstance interned [ty] Implemented support for "rename" language server feature (#19551) [ty] Reduce size of member table (#19572) [ty] Move server capabilities creation (#19798) separate types! tmp allow KnownInstance::TypeVar in type expressions bind typevar in Generic/Protocol base class reference [ty] Repurpose `FunctionType.into_bound_method_type` to return `BoundMethodType` (#19793) remove unneeded GenericContext::with_binding_context create KnownInstanceType::TypeVar for PEP 695 too ...
## Summary This PR adds reference documentation for the two new editor settings that were added in astral-sh/ruff#19800 and astral-sh/ruff#19780. ## Test Plan <img width="2491" height="1374" alt="Screenshot 2025-08-07 at 19 24 44" src="https://github.com/user-attachments/assets/f0fc32c5-1045-4fd9-900d-c4e7e429d54f" />
Summary
This PR is a follow-up from #19551 and adds a new
ty.experimental.renamesetting to conditionally register for the rename capability. The complementary PR in ty VS Code extension is astral-sh/ty-vscode#111.This is done using dynamic registration after the settings have been resolved. The experimental group is part of the global settings because they're applied for all workspaces that are managed by the client.
Test Plan
Add E2E tests.
In VS Code, with the following setting:
{ "ty.experimental.rename": "true", "python.languageServer": "None" }I get the relevant log entry:
And, I'm able to rename a symbol. Once I set it to
false, then I can see this log entry:And, I don't see the "Rename Symbol" open in the VS Code dropdown.
Screen.Recording.2025-08-07.at.16.08.26.mov