@zzzen/pyright-internal 1.2.0-dev.20250907 → 1.2.0-dev.20250914
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/checker.d.ts +1 -5
- package/dist/analyzer/checker.js +1 -90
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/program.js +8 -9
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +1 -2
- package/dist/analyzer/sourceFile.js +5 -4
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/common/configOptions.d.ts +0 -1
- package/dist/common/configOptions.js +0 -5
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnostic.d.ts +0 -8
- package/dist/common/diagnostic.js +1 -5
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +0 -1
- package/dist/common/diagnosticRules.js +0 -1
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +0 -29
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +0 -8
- package/dist/localization/localize.js +0 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -3
- package/dist/localization/package.nls.de.json +1 -3
- package/dist/localization/package.nls.en-us.json +1 -6
- package/dist/localization/package.nls.es.json +1 -3
- package/dist/localization/package.nls.fr.json +1 -3
- package/dist/localization/package.nls.it.json +1 -3
- package/dist/localization/package.nls.ja.json +1 -3
- package/dist/localization/package.nls.ko.json +1 -3
- package/dist/localization/package.nls.pl.json +1 -3
- package/dist/localization/package.nls.pt-br.json +1 -3
- package/dist/localization/package.nls.qps-ploc.json +1 -3
- package/dist/localization/package.nls.ru.json +1 -3
- package/dist/localization/package.nls.tr.json +1 -3
- package/dist/localization/package.nls.zh-cn.json +1 -3
- package/dist/localization/package.nls.zh-tw.json +1 -3
- package/dist/tests/service.test.js +44 -3
- package/dist/tests/service.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +0 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.js +0 -88
- package/dist/tests/fourslash/shadowedImports.fourslash.js.map +0 -1
|
@@ -2,12 +2,10 @@ import { AssertNode, AssignmentExpressionNode, AssignmentNode, AugmentedAssignme
|
|
|
2
2
|
import { ParserOutput } from '../parser/parser';
|
|
3
3
|
import { ImportResolver } from './importResolver';
|
|
4
4
|
import { ParseTreeWalker } from './parseTreeWalker';
|
|
5
|
-
import { SourceMapper } from './sourceMapper';
|
|
6
5
|
import { TypeEvaluator } from './typeEvaluatorTypes';
|
|
7
6
|
export declare class Checker extends ParseTreeWalker {
|
|
8
7
|
private _importResolver;
|
|
9
8
|
private _evaluator;
|
|
10
|
-
private _sourceMapper;
|
|
11
9
|
private _dependentFiles?;
|
|
12
10
|
private readonly _moduleNode;
|
|
13
11
|
private readonly _fileInfo;
|
|
@@ -15,7 +13,7 @@ export declare class Checker extends ParseTreeWalker {
|
|
|
15
13
|
private _scopedNodes;
|
|
16
14
|
private _typeParamLists;
|
|
17
15
|
private _multipartImports;
|
|
18
|
-
constructor(_importResolver: ImportResolver, _evaluator: TypeEvaluator, parseResults: ParserOutput,
|
|
16
|
+
constructor(_importResolver: ImportResolver, _evaluator: TypeEvaluator, parseResults: ParserOutput, _dependentFiles?: ParserOutput[] | undefined);
|
|
19
17
|
check(): void;
|
|
20
18
|
walk(node: ParseNode): void;
|
|
21
19
|
visitSuite(node: SuiteNode): boolean;
|
|
@@ -118,8 +116,6 @@ export declare class Checker extends ParseTreeWalker {
|
|
|
118
116
|
private _reportDeprecatedUseForType;
|
|
119
117
|
private _reportDeprecatedDiagnostic;
|
|
120
118
|
private _reportUnboundName;
|
|
121
|
-
private _conditionallyReportShadowedModule;
|
|
122
|
-
private _conditionallyReportShadowedImport;
|
|
123
119
|
private _conditionallyReportPrivateUsage;
|
|
124
120
|
private _validateEnumClassOverride;
|
|
125
121
|
private _validateTypedDictClassSuite;
|
package/dist/analyzer/checker.js
CHANGED
|
@@ -37,7 +37,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.Checker = void 0;
|
|
40
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
41
40
|
const collectionUtils_1 = require("../common/collectionUtils");
|
|
42
41
|
const debug_1 = require("../common/debug");
|
|
43
42
|
const diagnostic_1 = require("../common/diagnostic");
|
|
@@ -45,7 +44,6 @@ const diagnosticRules_1 = require("../common/diagnosticRules");
|
|
|
45
44
|
const pythonVersion_1 = require("../common/pythonVersion");
|
|
46
45
|
const textRange_1 = require("../common/textRange");
|
|
47
46
|
const uri_1 = require("../common/uri/uri");
|
|
48
|
-
const definitionProvider_1 = require("../languageService/definitionProvider");
|
|
49
47
|
const localize_1 = require("../localization/localize");
|
|
50
48
|
const parseNodes_1 = require("../parser/parseNodes");
|
|
51
49
|
const stringTokenUtils_1 = require("../parser/stringTokenUtils");
|
|
@@ -80,11 +78,10 @@ const typeUtils_1 = require("./typeUtils");
|
|
|
80
78
|
// functions to be emitted.
|
|
81
79
|
const isPrintCodeComplexityEnabled = false;
|
|
82
80
|
class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
83
|
-
constructor(_importResolver, _evaluator, parseResults,
|
|
81
|
+
constructor(_importResolver, _evaluator, parseResults, _dependentFiles) {
|
|
84
82
|
super();
|
|
85
83
|
this._importResolver = _importResolver;
|
|
86
84
|
this._evaluator = _evaluator;
|
|
87
|
-
this._sourceMapper = _sourceMapper;
|
|
88
85
|
this._dependentFiles = _dependentFiles;
|
|
89
86
|
this._isUnboundCheckSuppressed = false;
|
|
90
87
|
// A list of all nodes that are defined within the module that
|
|
@@ -99,7 +96,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
99
96
|
}
|
|
100
97
|
check() {
|
|
101
98
|
this._scopedNodes.push(this._moduleNode);
|
|
102
|
-
this._conditionallyReportShadowedModule();
|
|
103
99
|
// Report code complexity issues for the module.
|
|
104
100
|
const codeComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(this._moduleNode);
|
|
105
101
|
if (isPrintCodeComplexityEnabled) {
|
|
@@ -955,7 +951,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
955
951
|
return false;
|
|
956
952
|
}
|
|
957
953
|
visitImportAs(node) {
|
|
958
|
-
this._conditionallyReportShadowedImport(node);
|
|
959
954
|
this._evaluator.evaluateTypesForStatement(node);
|
|
960
955
|
const nameParts = node.d.module.d.nameParts;
|
|
961
956
|
if (nameParts.length > 1 && !node.d.alias) {
|
|
@@ -972,7 +967,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
972
967
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.futureImportLocationNotAllowed(), node);
|
|
973
968
|
}
|
|
974
969
|
}
|
|
975
|
-
this._conditionallyReportShadowedImport(node);
|
|
976
970
|
if (!node.d.isWildcardImport) {
|
|
977
971
|
node.d.imports.forEach((importAs) => {
|
|
978
972
|
this._evaluator.evaluateTypesForStatement(importAs);
|
|
@@ -3119,89 +3113,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3119
3113
|
}
|
|
3120
3114
|
}
|
|
3121
3115
|
}
|
|
3122
|
-
_conditionallyReportShadowedModule() {
|
|
3123
|
-
if (this._fileInfo.diagnosticRuleSet.reportShadowedImports === 'none') {
|
|
3124
|
-
return;
|
|
3125
|
-
}
|
|
3126
|
-
// Check the module we're in.
|
|
3127
|
-
const moduleName = this._fileInfo.moduleName;
|
|
3128
|
-
const desc = {
|
|
3129
|
-
nameParts: moduleName.split('.'),
|
|
3130
|
-
leadingDots: 0,
|
|
3131
|
-
importedSymbols: new Set(),
|
|
3132
|
-
};
|
|
3133
|
-
const stdlibPath = this._importResolver.getTypeshedStdLibPath(this._fileInfo.executionEnvironment);
|
|
3134
|
-
if (stdlibPath &&
|
|
3135
|
-
this._importResolver.isStdlibModule(desc, this._fileInfo.executionEnvironment) &&
|
|
3136
|
-
this._sourceMapper.isUserCode(this._fileInfo.fileUri)) {
|
|
3137
|
-
// This means the user has a module that is overwriting the stdlib module.
|
|
3138
|
-
const diag = this._evaluator.addDiagnosticForTextRange(this._fileInfo, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.LocMessage.stdlibModuleOverridden().format({
|
|
3139
|
-
name: moduleName,
|
|
3140
|
-
path: this._fileInfo.fileUri.toUserVisibleString(),
|
|
3141
|
-
}), this._moduleNode);
|
|
3142
|
-
// Add a quick action that renames the file.
|
|
3143
|
-
if (diag) {
|
|
3144
|
-
const renameAction = {
|
|
3145
|
-
action: "renameShadowedFile" /* ActionKind.RenameShadowedFileAction */,
|
|
3146
|
-
oldUri: this._fileInfo.fileUri,
|
|
3147
|
-
newUri: this._sourceMapper.getNextFileName(this._fileInfo.fileUri),
|
|
3148
|
-
};
|
|
3149
|
-
diag.addAction(renameAction);
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
_conditionallyReportShadowedImport(node) {
|
|
3154
|
-
if (this._fileInfo.diagnosticRuleSet.reportShadowedImports === 'none') {
|
|
3155
|
-
return;
|
|
3156
|
-
}
|
|
3157
|
-
// Skip this check for relative imports.
|
|
3158
|
-
const nodeModule = node.nodeType === 26 /* ParseNodeType.ImportFromAs */
|
|
3159
|
-
? node.parent?.nodeType === 25 /* ParseNodeType.ImportFrom */
|
|
3160
|
-
? node.parent?.d.module
|
|
3161
|
-
: undefined
|
|
3162
|
-
: node.d.module;
|
|
3163
|
-
if (nodeModule?.d.leadingDots) {
|
|
3164
|
-
return;
|
|
3165
|
-
}
|
|
3166
|
-
// Otherwise use the name to determine if a match for a stdlib module.
|
|
3167
|
-
const namePartNodes = node.nodeType === 24 /* ParseNodeType.ImportAs */
|
|
3168
|
-
? node.d.module.d.nameParts
|
|
3169
|
-
: node.nodeType === 26 /* ParseNodeType.ImportFromAs */
|
|
3170
|
-
? [node.d.name]
|
|
3171
|
-
: node.d.module.d.nameParts;
|
|
3172
|
-
const nameParts = namePartNodes.map((n) => n.d.value);
|
|
3173
|
-
const module = {
|
|
3174
|
-
nameParts,
|
|
3175
|
-
leadingDots: 0,
|
|
3176
|
-
importedSymbols: new Set(),
|
|
3177
|
-
};
|
|
3178
|
-
// Make sure the module is a potential stdlib one so we don't spend the time
|
|
3179
|
-
// searching for the definition.
|
|
3180
|
-
const stdlibPath = this._importResolver.getTypeshedStdLibPath(this._fileInfo.executionEnvironment);
|
|
3181
|
-
if (stdlibPath && this._importResolver.isStdlibModule(module, this._fileInfo.executionEnvironment)) {
|
|
3182
|
-
// If the definition for this name is in 'user' module, it is overwriting the stdlib module.
|
|
3183
|
-
const definitions = definitionProvider_1.DefinitionProvider.getDefinitionsForNode(this._sourceMapper, this._evaluator, namePartNodes[namePartNodes.length - 1], namePartNodes[namePartNodes.length - 1].start, vscode_languageserver_1.CancellationToken.None);
|
|
3184
|
-
const paths = definitions ? definitions.map((d) => d.uri) : [];
|
|
3185
|
-
paths.forEach((p) => {
|
|
3186
|
-
if (!p.startsWith(stdlibPath) && !(0, sourceMapper_1.isStubFile)(p) && this._sourceMapper.isUserCode(p)) {
|
|
3187
|
-
// This means the user has a module that is overwriting the stdlib module.
|
|
3188
|
-
const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.LocMessage.stdlibModuleOverridden().format({
|
|
3189
|
-
name: nameParts.join('.'),
|
|
3190
|
-
path: p.toUserVisibleString(),
|
|
3191
|
-
}), node);
|
|
3192
|
-
// Add a quick action that renames the file.
|
|
3193
|
-
if (diag) {
|
|
3194
|
-
const renameAction = {
|
|
3195
|
-
action: "renameShadowedFile" /* ActionKind.RenameShadowedFileAction */,
|
|
3196
|
-
oldUri: p,
|
|
3197
|
-
newUri: this._sourceMapper.getNextFileName(p),
|
|
3198
|
-
};
|
|
3199
|
-
diag.addAction(renameAction);
|
|
3200
|
-
}
|
|
3201
|
-
}
|
|
3202
|
-
});
|
|
3203
|
-
}
|
|
3204
|
-
}
|
|
3205
3116
|
_conditionallyReportPrivateUsage(node) {
|
|
3206
3117
|
if (this._fileInfo.diagnosticRuleSet.reportPrivateUsage === 'none') {
|
|
3207
3118
|
return;
|