Skip to content

Conversation

BurntSushi
Copy link
Member

Specifically, this PR reverts "Make completions an opt-in LSP feature (#17921)",
corresponding to commit 51e2eff.

In practice, this means you don't need to opt into completions working
by enabling experimental features. i.e., I was able to remove this from
my LSP configuration:

"experimental": {
    "completions": {
        "enable": true
    }
},

There's still a lot of work left to do to make completions awesome, but
I think it's in a state where it would be useful to get real user
feedback. It's also meaningfully using ty to provide completions that
use type information.

Ref astral-sh/ty#86

Specifically, this PR reverts "Make completions an opt-in LSP feature (#17921)",
corresponding to commit 51e2eff.

In practice, this means you don't need to opt into completions working
by enabling experimental features. i.e., I was able to remove this from
my LSP configuration:

```
"experimental": {
    "completions": {
        "enable": true
    }
},
```

There's still a lot of work left to do to make completions awesome, but
I think it's in a state where it would be useful to get real user
feedback. It's also meaningfully using ty to provide completions that
use type information.

Ref astral-sh/ty#86
Copy link
Contributor

mypy_primer results

No ecosystem changes detected ✅

@BurntSushi BurntSushi requested review from dhruvmanila and removed request for dcreager June 12, 2025 19:03
@MichaReiser
Copy link
Member

I think @dhruvmanila expressed some concerns around stabilizing the feature. We should make sure that he reviewed this PR before merging.

/// This is a direct representation of the settings schema sent by the client.
#[derive(Debug, Deserialize, Default)]
#[cfg_attr(test, derive(PartialEq, Eq))]
#[serde(rename_all = "camelCase")]
pub struct ClientSettings {
pub(crate) experimental: Option<Experimental>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, technically, a breaking change. I think it's fine, considering where we're at with ty.

We'll also need to update the ty-vscode extension to no longer list this option and update the documentation as well.

@MichaReiser MichaReiser added server Related to the LSP server ty Multi-file analysis & type inference breaking Breaking API change labels Jun 13, 2025
@dhruvmanila
Copy link
Member

At this stage, the ty language server doesn't have all the capabilities that a developer might use on a daily basis e.g., go to definition, rename, etc. This means that it's more than likely that the ty language server will be used alongside another language server (e.g., Pyright) to provide other capabilities. Now, if we stabilize this i.e., show completions without opt-in, it would mean that the completion menu would contain duplicate entries from both the language server.

One way to solve this, and is a solution that Pyrefly has implemented, would be to provide a python.ty.disableLanguageServices option that disables all the language services from ty and then the server will be used only for providing type checking diagnostics. This is something that I've implemented here but is currently blocked on an upstream change (microsoft/vscode-python#25041). This would mainly be useful in VS Code where we would add support for recognizing this option in the Python extension so that it can disable the Pylance language server when the user wants to use ty language server exclusively.

The above solution is not granular as it would either enable all language features or disable them, nothing in between. Another solution would be to provide granular configuration, like allowing users to use completions from ty but navigation capabilities like goto definition, declaration, etc. from another language server. Or, an even granular options that allows users to enable / disable each capability.

tl;dr The main issue here is how do we allow users to keep using ty server's capabilities even when another language server is active. I'd prefer if we can wait until we have the python.ty.disableLanguageServices option in, so that users can still use ty for type checking and keep using another language server for other capabilities.

That said, I think we could still merge the PRs for adding the above config option on ty's side so that there's still an option for users to opt-out of language services like auto-completions.

@BurntSushi
Copy link
Member Author

Hmmm okay. Do we already have a problem today with conflicting LSPs running simultaneously? e.g., If you do a goto type definition request with ty and pyright enabled, which one services it?

Another issue I see is that even if we offer granular enable/disable options, that still seemingly requires the other LSP you use to also have granular enable/disable options.

I'm fine waiting here for python.ty.disableLanguageServices, but I'd prefer not doing that if it's truly blocked on upstream.

@dhruvmanila
Copy link
Member

dhruvmanila commented Jun 13, 2025

I think what we can do is:

  1. Merge this PR stabilizing completions
  2. I'll make the python.ty.disableLanguageServices PRs ready for review for the ty server and ty VS Code extension
  3. I'll open a PR in the Python extension to at least detect this option
  4. I'll see if I can fix the issue as stated in [RFC] watch pyrefly settings microsoft/vscode-python#25041 in that PR

Pyrefly has a hack that does the refresh on their VS Code extension. I'd prefer and see if I can just fix the issue on the Python extension side. I just didn't prioritized it as it wasn't that helpful earlier but given that completions would be available it might be useful to prioritize that now.

@dhruvmanila
Copy link
Member

So, all in all, I'm fine moving ahead with this PR.

We should also remove this option from https://github.com/astral-sh/ty/blob/main/docs/reference/editor-settings.md#experimental.

@dhruvmanila
Copy link
Member

Hmmm okay. Do we already have a problem today with conflicting LSPs running simultaneously? e.g., If you do a goto type definition request with ty and pyright enabled, which one services it?

I think this depends on client implementation. For example, Neovim supports multiple servers for navigation capabilities like goto type definition where it'll collect all the locations for the request from all the available language servers and provide them as quickfix list so you can navigate through all available options.

BurntSushi added a commit to astral-sh/ty that referenced this pull request Jun 13, 2025
This was only used to opt into completions. But we're removing the
opt-in in astral-sh/ruff#18650, so let's remove
it from the docs too.

Ref #86
@sharkdp sharkdp removed their request for review June 14, 2025 07:39
BurntSushi added a commit to astral-sh/ty that referenced this pull request Jun 16, 2025
This was only used to opt into completions. But we're removing the
opt-in in astral-sh/ruff#18650, so let's remove
it from the docs too.

Ref #86
@BurntSushi BurntSushi merged commit 869d7bf into main Jun 16, 2025
35 checks passed
@BurntSushi BurntSushi deleted the ag/stabilize-completions branch June 16, 2025 11:44
dcreager added a commit that referenced this pull request Jun 16, 2025
* main: (38 commits)
  [`pyupgrade`] Suppress `UP008` diagnostic if `super` symbol is not builtin (#18688)
  [pylint] Fix `PLW0128` to check assignment targets in square brackets and after asterisks (#18665)
  [`refurb`] Make the fix for `FURB163` unsafe for `log2`, `log10`, `*args`, and deleted comments (#18645)
  [ty] allow `T: Never` as subtype of `Never` (#18687)
  [ty] Use more parallelism when running corpus tests (#18711)
  [ty] Support `dataclasses.KW_ONLY` (#18677)
  [`ruff`] Check for non-context-manager use of `pytest.raises`, `pytest.warns`, and `pytest.deprecated_call` (`RUF061`) (#17368)
  Add syntax error when conversion flag does not immediately follow exclamation mark (#18706)
  [`flake8-pyi`] Fix `custom-typevar-for-self` with string annotations (`PYI019`) (#18311)
  Drop confusing second `*` from glob pattern example (#18709)
  [ty] Stabilize completions (#18650)
  [ty] Correctly label typeshed-sync PRs (#18702)
  Update Rust crate memchr to v2.7.5 (#18696)
  Update dependency react-resizable-panels to v3.0.3 (#18691)
  Update Rust crate clap to v4.5.40 (#18692)
  Update Rust crate libcst to v1.8.2 (#18695)
  Update Rust crate jiff to v0.2.15 (#18693)
  Update Rust crate libc to v0.2.173 (#18694)
  Update Rust crate syn to v2.0.103 (#18698)
  Update Rust crate toml to v0.8.23 (#18699)
  ...
dhruvmanila added a commit to astral-sh/ty-vscode that referenced this pull request Jun 17, 2025
## Summary

Following up on astral-sh/ruff#18650, this PR
removes the `experimental.completions.enable` config from the extension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change server Related to the LSP server ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants