Skip to content

Delegate Pylance language-client lifecycle with compatibility fallback - #25370

Open
Bill Schnurr (bschnurr) wants to merge 15 commits into
microsoft:mainfrom
bschnurr:remove-pylance-client2
Open

Bill Schnurr (bschnurr) wants to merge 15 commits into
microsoft:mainfrom
bschnurr:remove-pylance-client2

Conversation

@bschnurr

@bschnurr Bill Schnurr (bschnurr) commented Aug 8, 2025 •

Copy link
Copy Markdown
Member

Description

Move Pylance language-client lifecycle ownership to Pylance while preserving compatibility with independently updated Python and Pylance extensions.

Python advertises support for the new lifecycle and delegates start, stop, and restart when Pylance advertises self-management. The existing Python-managed path and client APIs remain available for older Pylance versions. The existing language-server output channel is shared during the transition.

Companion Pylance draft: https://github.com/microsoft/pyrx/pull/10248

Testing

  • Python type-check and targeted formatting and lint.
  • 35 affected language-server unit tests.
  • Real desktop host: new extensions together and both update orders, including completion, output channel, mode switching, and restart.
  • Real web host: paired new extensions passed six tests, including lifecycle switching. The runner logged ERR_STREAM_PREMATURE_CLOSE during shutdown.

The Python desktop test bundle used a temporary webpack configuration to filter external modules after prior test compilation affected external-module discovery.

Comment thread src/client/browser/api.ts
new LanguageClient(PYTHON_LANGUAGE, 'Python Language Server', args[0], args[1]),
start: (client: BaseLanguageClient): Promise<void> => client.start(),
stop: (client: BaseLanguageClient): Promise<void> => client.stop(),
getTelemetryReporter: () => reporter,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

keeping getTelemetryReporter() removing others

const api = pylanceExtension.exports;
if (api.client && api.client.isEnabled()) {
pylanceApi = api;
await api.client.start();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just removing this call to start. not sure why the diff is messed up. My other idea was to leave this logic in. but change pylance's api.client.isEnabled() to return false and then just return in that case.

Comment thread src/client/common/utils/localize.ts Outdated

export namespace OutputChannelNames {
export const languageServer = l10n.t('Python Language Server');
export const JediLanguageServer = l10n.t('Jedi');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

renamed Jedi's output window to 'Jedi'

this.serverManager.dispose();
this.serverProxy.dispose();
this.analysisOptions.dispose();
this.outputChannel.dispose();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

now dispose Jedi's output channel here instead of the global one

Comment thread src/client/api.ts
},
start: (client: BaseLanguageClient): Promise<void> => client.start(),
stop: (client: BaseLanguageClient): Promise<void> => client.stop(),
getTelemetryReporter: () => getTelemetryReporter(),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

diff is messed up, removing createClient, start, stop

Comment thread src/client/pylanceApi.ts
createClient(...args: any[]): BaseLanguageClient;
start(client: BaseLanguageClient): Promise<void>;
stop(client: BaseLanguageClient): Promise<void>;
getTelemetryReporter(): TelemetryReporter;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removing

	createClient(...args: any[]): BaseLanguageClient;
    start(client: BaseLanguageClient): Promise<void>;
    stop(client: BaseLanguageClient): Promise<void>;

@bschnurr Bill Schnurr (bschnurr) added the feature-request Request for new features or functionality label Aug 11, 2025
@bschnurr
Bill Schnurr (bschnurr) marked this pull request as ready for review August 11, 2025 17:10
this.analysisOptions = new JediLanguageServerAnalysisOptions(
environmentService,
outputChannel,
this.outputChannel,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

extension manager now owns the output channel

Comment thread src/client/api.ts
},
},
pylance: {
createClient: (...args: any[]): BaseLanguageClient => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

remove pylance apis except getTelemetryReporter

@eleanorjboyd

Copy link
Copy Markdown

Bill Schnurr (@bschnurr) what is the status on this PR?

@bschnurr

Copy link
Copy Markdown
Member Author

This was a first attempt to see if i was on the right track.

@bschnurr

Copy link
Copy Markdown
Member Author

Bill Schnurr (@bschnurr) what is the status on this PR?

i'll update and see if it still builds.. one outstanding question i had was is it ok to only support the latest pylance going forward?

@eleanorjboyd

Copy link
Copy Markdown

Karthik Nadig (@karthiknadig) would be able to answer that question better

@karthiknadig

Copy link
Copy Markdown
Member

Bill Schnurr (@bschnurr) Yes, support only the latest is fine. But to do this I recommend updating the VS Code engine versions in both Python and Pylance extensions. This way when users get the latest Python extension, it will match the VS Code engine for both python and pylance, making them both latest.

Version checking in the code is OK. But it can still trigger a lot of different types of hard to find problems.

@eleanorjboyd

Copy link
Copy Markdown

hi Bill Schnurr (@bschnurr) wanted to follow up. Did you update the engine version request? What is the status of this PR? Thanks

@bschnurr

Copy link
Copy Markdown
Member Author

sorry. totally forgot about this PR. some major Pylance had some major startup rewrites. need to test this again

Keep the legacy client API for older Pylance versions and delegate lifecycle management when supported.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bschnurr Bill Schnurr (bschnurr) changed the title remove pylance create,start,stop. Pylance will now do that itself. Delegate Pylance language-client lifecycle with compatibility fallback Nov 25, 2026
@StellaHuang95

Stella Huang (StellaHuang95) commented Nov 25, 2026 •

Copy link
Copy Markdown

🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR.

@StellaHuang95

Stella Huang (StellaHuang95) commented Nov 25, 2026 •

Copy link
Copy Markdown

Reviewed commit: f288d97670f2fcf371a41715334386929386e19e

Result: 🔴 could-not-verify

Verification details

Verification: Automated verification is best effort. The PR author remains responsible for testing.

Summary: [unavailable] Container verification could not start and local execution was not authorized for this PR HEAD: Podman CLI is not installed or is not on PATH.

Test runs: none recorded.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved via Review Center.

@StellaHuang95 Stella Huang (StellaHuang95) added the review-auto:approved Automated review: no blocking findings (approval posted). label Nov 25, 2026

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved via Review Center.

The test was removed with PylanceLSExtensionManager; that manager is back as the compatibility fallback, so restore coverage using the current watcher constructor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajushikdar1992-create

Copy link
Copy Markdown

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 review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants