Skip to content
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

[PylanceBot] Pull Pylance with Pyright 1.1.377 #8808

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions packages/pyright-internal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions packages/pyright-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"leven": "3.1.0",
"source-map-support": "^0.5.21",
"tmp": "^0.2.1",
"vscode-jsonrpc": "^9.0.0-next.4",
"vscode-languageserver": "^10.0.0-next.6",
"vscode-jsonrpc": "^9.0.0-next.2",
"vscode-languageserver": "^10.0.0-next.2",
"vscode-languageserver-protocol": "^3.17.6-next.3",
"vscode-languageserver-textdocument": "1.0.11",
"vscode-languageserver-types": "^3.17.6-next.4",
"vscode-languageserver-types": "^3.17.6-next.3",
bschnurr marked this conversation as resolved.
Show resolved Hide resolved
"vscode-uri": "^3.0.8"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/importResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export class ImportResolver {
}

getTypeshedStdlibExcludeList(
customTypeshedPath: Uri,
customTypeshedPath: Uri | undefined,
pythonVersion: PythonVersion,
pythonPlatform: string | undefined
): Uri[] {
Expand Down
70 changes: 37 additions & 33 deletions packages/pyright-internal/src/analyzer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class AnalyzerService {
this._backgroundAnalysisProgram.setConfigOptions(configOptions);

this._executionRootUri = configOptions.projectRoot;
this._applyConfigOptions(host);
this.applyConfigOptions(host);
bschnurr marked this conversation as resolved.
Show resolved Hide resolved
}

hasSourceFile(uri: Uri): boolean {
Expand Down Expand Up @@ -472,11 +472,41 @@ export class AnalyzerService {
// Forces the service to stop all analysis, discard all its caches,
// and research for files.
restart() {
this._applyConfigOptions(this._hostFactory());
this.applyConfigOptions(this._hostFactory());

this._backgroundAnalysisProgram.restart();
}

protected applyConfigOptions(host: Host) {
// Allocate a new import resolver because the old one has information
// cached based on the previous config options.
const importResolver = this._importResolverFactory(
this._serviceProvider,
this._backgroundAnalysisProgram.configOptions,
host
);

this._backgroundAnalysisProgram.setImportResolver(importResolver);

if (this._commandLineOptions?.fromLanguageServer || this._configOptions.verboseOutput) {
const logLevel = this._configOptions.verboseOutput ? LogLevel.Info : LogLevel.Log;
for (const execEnv of this._configOptions.getExecutionEnvironments()) {
log(this._console, logLevel, `Search paths for ${execEnv.root || '<default>'}`);
const roots = importResolver.getImportRoots(execEnv, /* forLogging */ true);
roots.forEach((path) => {
log(this._console, logLevel, ` ${path.toUserVisibleString()}`);
});
}
}

this._updateLibraryFileWatcher();
this._updateConfigFileWatcher();
this._updateSourceFileWatchers();
this._updateTrackedFileList(/* markFilesDirtyUnconditionally */ true);

this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
}

private get _console() {
return this._options.console!;
}
Expand Down Expand Up @@ -620,6 +650,9 @@ export class AnalyzerService {
);
}

// Set the configFileSource since we have a config file.
configOptions.configFileSource = configFilePath ?? pyprojectFilePath;

// When not in language server mode, command line options override config file options.
if (!commandLineOptions.fromLanguageServer) {
this._applyCommandLineOverrides(configOptions, commandLineOptions.configSettings, projectRoot, false);
Expand Down Expand Up @@ -895,6 +928,7 @@ export class AnalyzerService {
});

configOptions.applyDiagnosticOverrides(commandLineOptions.diagnosticSeverityOverrides);
configOptions.applyDiagnosticOverrides(commandLineOptions.diagnosticBooleanOverrides);

// Override the analyzeUnannotatedFunctions setting based on the command-line setting.
if (commandLineOptions.analyzeUnannotatedFunctions !== undefined) {
Expand Down Expand Up @@ -1779,40 +1813,10 @@ export class AnalyzerService {
const configOptions = this._getConfigOptions(host, this._commandLineOptions!);
this._backgroundAnalysisProgram.setConfigOptions(configOptions);

this._applyConfigOptions(host);
this.applyConfigOptions(host);
}
}

private _applyConfigOptions(host: Host) {
// Allocate a new import resolver because the old one has information
// cached based on the previous config options.
const importResolver = this._importResolverFactory(
this._serviceProvider,
this._backgroundAnalysisProgram.configOptions,
host
);

this._backgroundAnalysisProgram.setImportResolver(importResolver);

if (this._commandLineOptions?.fromLanguageServer || this._configOptions.verboseOutput) {
const logLevel = this._configOptions.verboseOutput ? LogLevel.Info : LogLevel.Log;
for (const execEnv of this._configOptions.getExecutionEnvironments()) {
log(this._console, logLevel, `Search paths for ${execEnv.root || '<default>'}`);
const roots = importResolver.getImportRoots(execEnv, /* forLogging */ true);
roots.forEach((path) => {
log(this._console, logLevel, ` ${path.toUserVisibleString()}`);
});
}
}

this._updateLibraryFileWatcher();
this._updateConfigFileWatcher();
this._updateSourceFileWatchers();
this._updateTrackedFileList(/* markFilesDirtyUnconditionally */ true);

this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
}

private _clearReanalysisTimer() {
if (this._analyzeTimer) {
clearTimeout(this._analyzeTimer);
Expand Down
Loading
Loading