mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Use typeshed version info for stdlib module list (#7982)
This commit is contained in:
parent
50d4f44735
commit
bfc60526a0
@ -338,7 +338,7 @@ export class ImportResolver {
|
||||
|
||||
isStdlibModule(module: ImportedModuleDescriptor, execEnv: ExecutionEnvironment): boolean {
|
||||
if (!this._stdlibModules) {
|
||||
this._stdlibModules = this._buildStdlibCache(this.getTypeshedStdLibPath(execEnv));
|
||||
this._stdlibModules = this._buildStdlibCache(this.getTypeshedStdLibPath(execEnv), execEnv);
|
||||
}
|
||||
|
||||
return this._stdlibModules.has(module.nameParts.join('.'));
|
||||
@ -1895,7 +1895,7 @@ export class ImportResolver {
|
||||
}
|
||||
|
||||
// Finds all of the stdlib modules and returns a Set containing all of their names.
|
||||
private _buildStdlibCache(stdlibRoot: Uri | undefined): Set<string> {
|
||||
private _buildStdlibCache(stdlibRoot: Uri | undefined, executionEnvironment: ExecutionEnvironment): Set<string> {
|
||||
const cache = new Set<string>();
|
||||
|
||||
if (stdlibRoot) {
|
||||
@ -1908,7 +1908,17 @@ export class ImportResolver {
|
||||
const stripped = stripFileExtension(entry.name);
|
||||
// Skip anything starting with an underscore.
|
||||
if (!stripped.startsWith('_')) {
|
||||
cache.add(prefix ? `${prefix}.${stripped}` : stripped);
|
||||
if (
|
||||
this._isStdlibTypeshedStubValidForVersion(
|
||||
createImportedModuleDescriptor(stripped),
|
||||
root,
|
||||
executionEnvironment.pythonVersion,
|
||||
executionEnvironment.pythonPlatform,
|
||||
[]
|
||||
)
|
||||
) {
|
||||
cache.add(prefix ? `${prefix}.${stripped}` : stripped);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user