Skip to content

Disable language services if Pyrefly extension installed + active #24987

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

Merged
merged 11 commits into from
Apr 23, 2025

Conversation

kinto0
Copy link

@kinto0 kinto0 commented Apr 16, 2025

For #24850

Summary:
Background:
A new typechecker called Pyrefly will be featured at Pycon with a talk, website/sandbox (still WIP), and extension (still WIP). This extension will provide ultrafast typechecking and language services. When the Pyrefly extension is installed, ms-python.python should not start Jedi or Pylance unless python.pyrefly.disableLanguageServices is set to true.

Test Plan:

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@karthiknadig karthiknadig requested a review from rchiodo April 16, 2025 20:45
@karthiknadig karthiknadig self-assigned this Apr 16, 2025
@karthiknadig karthiknadig self-requested a review April 16, 2025 20:45
@kinto0
Copy link
Author

kinto0 commented Apr 16, 2025

Thanks for the quick review @rchiodo! I did not realize you would see draft PRs yet... I just updated the summary so it should make more sense.

@rchiodo
Copy link

rchiodo commented Apr 16, 2025

When you did this part:

Followed guide here. When running extension locally, I don't see any language services ever (before / after my changes). I'd appreciate help testing this integration since I'm not confident the configuration is set correctl

Did you clone into the extensions folder for vscode? I think that's what those directions are asking you to do? @karthiknadig would know more. Pylance would have to be installed in the extensions folder I think for your testing to work

@rchiodo
Copy link

rchiodo commented Apr 16, 2025

This error:

2025-04-16 15:22:19.725 [error] [
  'Starting language server, Class name = p, completed in 11208ms, has a falsy return value, , Return Value: undefined',
  [Error: command 'pyright.createtypestub' already exists
  	at cw.registerCommand (file:///private/var/folders/x0/z3j4vbzs3wqd0ynb6q24jglm0000gn/T/AppTranslocation/58C97911-06B4-4CA7-9068-D7D7F655735D/d/Visual%20Studio%20Code%202.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:115:31527)
  	at Object.registerCommand (file:///private/var/folders/x0/z3j4vbzs3wqd0ynb6q24jglm0000gn/T/AppTranslocation/58C97911-06B4-4CA7-9068-D7D7F655735D/d/Visual%20Studio%20Code%202.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:157:36729)
  	at t.ExecuteCommandFeature.register (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:2101514)
  	at t.ExecuteCommandFeature.initialize (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:2101091)
  	at P.initializeFeatures (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:2041419)
  	at P.doInitialize (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:2027694)
  	at async P.start (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:2024707)
  	at async Object.start (/Users/kylei/.vscode/extensions/ms-python.vscode-pylance-2025.4.1/dist/extension.bundle.js:1:148233)
  	at async _0x317b05._startClient (/Users/kylei/.vscode/extensions/ms-python.vscode-pylance-2025.4.1/dist/extension.bundle.js:1:84298)
  	at async _0x317b05._createNewRequest (/Users/kylei/.vscode/extensions/ms-python.vscode-pylance-2025.4.1/dist/extension.bundle.js:1:83758)
  	at async _0x317b05._enqueueRequestAndWaitForRun (/Users/kylei/.vscode/extensions/ms-python.vscode-pylance-2025.4.1/dist/extension.bundle.js:1:83000)
  	at async _0x317b05.startClient (/Users/kylei/.vscode/extensions/ms-python.vscode-pylance-2025.4.1/dist/extension.bundle.js:1:82482)
  	at async h.start (/Users/kylei/.vscode/extensions/ms-python.python-2025.4.0-darwin-arm64/out/client/extension.js:2:39831)]
]

Usually happens when pyright and pylance are enabled at the same time. It might also happen if pylance is started twice for some reason.

@karthiknadig karthiknadig added the feature-request Request for new features or functionality label Apr 16, 2025
@karthiknadig
Copy link
Member

@kinto0 Please look into and accept the CLA. Otherwise we can't merge this.

kinto0 added 2 commits April 18, 2025 13:03
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@kinto0
Copy link
Author

kinto0 commented Apr 18, 2025

@microsoft-github-policy-service agree [company="{your company}"]

@microsoft-github-policy-service agree [company="meta"]

@kinto0
Copy link
Author

kinto0 commented Apr 18, 2025

@microsoft-github-policy-service agree company="your company"

@microsoft-github-policy-service agree company="meta"

kinto0 and others added 3 commits April 18, 2025 17:57
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@kinto0 kinto0 marked this pull request as ready for review April 18, 2025 23:36
rchiodo
rchiodo previously approved these changes Apr 18, 2025
Copy link

@Crazy40528 Crazy40528 left a comment

Choose a reason for hiding this comment

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

kinto0:kinto/disable-with-pyrefly

kinto0 added 2 commits April 21, 2025 12:02
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@kinto0 kinto0 requested a review from karthiknadig April 21, 2025 19:02
kinto0 added 2 commits April 21, 2025 22:23
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
@vs-code-engineering vs-code-engineering bot added this to the April 2025 milestone Apr 22, 2025
@karthiknadig karthiknadig merged commit 7fea432 into microsoft:main Apr 23, 2025
46 checks passed
facebook-github-bot pushed a commit to facebook/pyrefly that referenced this pull request May 7, 2025
…d on + vice-versa)

Summary:
ms-python insiders came out last night and it is not looking good for my [patch](microsoft/vscode-python#24987). When I put up the PR, I was not able to test pylance fully and put too much faith in the test framework (it's really good but not this good apparently).

It works great on a window reload, but that isn't good enough for testing.

two issues:
- installing pyrefly refreshes something but does not keep pylance disabled (green = pylance syntax highlighting)
{F1977750850}

I'm not sure what causes this. these settings are [re-checked on any extension install](https://github.com/microsoft/vscode-python/blob/a3dd3aa1bca82be1fb5c44f04c689233010eaeab/src/client/languageServer/watcher.ts#L345) (hence the flicker) and we [check for existence of pyrefly](https://github.com/microsoft/vscode-python/blob/a3dd3aa1bca82be1fb5c44f04c689233010eaeab/src/client/common/configSettings.ts#L283).

- changing the disableLanguageServices setting does not actually trigger the change
{F1977750864}

This is an easier fix: I must've messed up testing it [here](microsoft/vscode-python#24987 (comment))

In the meantime, this hack fixes both of these issues from within pyrefly with no side effects, but only if a workspace is opened (it does not work on the default workspace [because settings are not watched there](https://github.com/microsoft/vscode-python/blob/a3dd3aa1bca82be1fb5c44f04c689233010eaeab/src/client/languageServer/watcher.ts#L295))

Reviewed By: SamChou19815

Differential Revision: D74327314

fbshipit-source-id: 7d97476572731e8771af44af60c81d0d2334054d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
5 participants