mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-27 03:12:44 +03:00
Fixed a bug that caused incorrect type evaluation because of stale module paths that are cached for specific source files. Module paths are dependent on the list of configured import resolution paths, so when the import resolution paths change, we may need to recompute the module path for a source file.
This commit is contained in:
parent
05c46fc09a
commit
cdba65d4c8
@ -262,12 +262,16 @@ export class Program {
|
||||
|
||||
addTrackedFile(filePath: string, isThirdPartyImport = false, isInPyTypedPackage = false): SourceFile {
|
||||
let sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
|
||||
const importName = this._getImportNameForFile(filePath);
|
||||
|
||||
if (sourceFileInfo) {
|
||||
// The module name may have changed based on updates to the
|
||||
// search paths, so update it here.
|
||||
sourceFileInfo.sourceFile.setModuleName(importName);
|
||||
sourceFileInfo.isTracked = true;
|
||||
return sourceFileInfo.sourceFile;
|
||||
}
|
||||
|
||||
const importName = this._getImportNameForFile(filePath);
|
||||
const sourceFile = new SourceFile(
|
||||
this._fs,
|
||||
filePath,
|
||||
|
@ -97,7 +97,7 @@ export class SourceFile {
|
||||
private readonly _filePath: string;
|
||||
|
||||
// Period-delimited import path for the module.
|
||||
private readonly _moduleName: string;
|
||||
private _moduleName: string;
|
||||
|
||||
// True if file is a type-hint (.pyi) file versus a python
|
||||
// (.py) file.
|
||||
@ -247,6 +247,14 @@ export class SourceFile {
|
||||
return this._filePath;
|
||||
}
|
||||
|
||||
getModuleName(): string {
|
||||
return this._moduleName;
|
||||
}
|
||||
|
||||
setModuleName(name: string) {
|
||||
this._moduleName = name;
|
||||
}
|
||||
|
||||
getDiagnosticVersion(): number {
|
||||
return this._diagnosticVersion;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user