@zzzen/pyright-internal 1.2.0-dev.20230122 → 1.2.0-dev.20230205
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/backgroundAnalysisProgram.d.ts +3 -3
- package/dist/analyzer/backgroundAnalysisProgram.js +4 -2
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +16 -12
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +3 -1
- package/dist/analyzer/checker.js +63 -20
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +3 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +1 -1
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.js +4 -3
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +2 -0
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/enums.js +1 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +7 -3
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +1 -0
- package/dist/analyzer/parseTreeUtils.d.ts +2 -1
- package/dist/analyzer/parseTreeUtils.js +75 -10
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +1 -1
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +8 -4
- package/dist/analyzer/program.js +92 -24
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/service.d.ts +0 -2
- package/dist/analyzer/service.js +8 -8
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +4 -8
- package/dist/analyzer/sourceFile.js +5 -21
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.d.ts +8 -2
- package/dist/analyzer/typeCacheUtils.js +4 -4
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +247 -110
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +12 -8
- package/dist/analyzer/typeGuards.js +2 -16
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +5 -4
- package/dist/analyzer/typeUtils.js +41 -14
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +1 -5
- package/dist/analyzer/typeVarContext.js +17 -22
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typedDicts.js +6 -2
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +4 -1
- package/dist/analyzer/types.js +26 -2
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +1 -3
- package/dist/backgroundAnalysisBase.js +2 -3
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +6 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/configOptions.d.ts +5 -0
- package/dist/common/configOptions.js +19 -1
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +1 -1
- package/dist/common/envVarUtils.js +26 -16
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +44 -6
- package/dist/common/extensibility.js +26 -2
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +2 -1
- package/dist/common/fullAccessHost.js +22 -0
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +6 -0
- package/dist/common/host.js +3 -0
- package/dist/common/host.js.map +1 -1
- package/dist/common/pathUtils.d.ts +2 -0
- package/dist/common/pathUtils.js +17 -3
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +4 -5
- package/dist/languageServerBase.js +5 -6
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +1 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +0 -1
- package/dist/languageService/completionProvider.js +21 -99
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +34 -0
- package/dist/languageService/completionProviderUtils.js +102 -0
- package/dist/languageService/completionProviderUtils.js.map +1 -0
- package/dist/languageService/definitionProvider.d.ts +2 -1
- package/dist/languageService/definitionProvider.js +25 -9
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +2 -1
- package/dist/languageService/documentSymbolCollector.js +27 -3
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +1 -1
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +3 -1
- package/dist/languageService/hoverProvider.js +51 -37
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +2 -1
- package/dist/languageService/referencesProvider.js +4 -3
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +7 -1
- package/dist/languageService/tooltipUtils.js +81 -4
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +7 -0
- package/dist/localization/localize.js +9 -9
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +2 -2
- package/dist/parser/parseNodes.js +0 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/stringTokenUtils.js +10 -0
- package/dist/parser/stringTokenUtils.js.map +1 -1
- package/dist/pyright.js +17 -9
- package/dist/pyright.js.map +1 -1
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js +5 -5
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.commitChars.fourslash.js +23 -1
- package/dist/tests/fourslash/completions.commitChars.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.localCode.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.overloads.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.plainText.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.self.fourslash.js +2 -2
- package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +1 -1
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +2 -2
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js +7 -7
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.class.docString.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +7 -7
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +3 -3
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.formatted.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.formatted.fourslash.js +45 -0
- package/dist/tests/fourslash/hover.formatted.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +6 -6
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js +5 -5
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +4 -4
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js +4 -4
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.libStub.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js +2 -2
- package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.multipart.fourslash.js +1 -1
- package/dist/tests/fourslash/import.multipart.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js +1 -1
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +2 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +0 -10
- package/dist/tests/harness/fourslash/testState.js +15 -68
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.d.ts +12 -0
- package/dist/tests/harness/fourslash/testStateUtils.js +98 -0
- package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -0
- package/dist/tests/pathUtils.test.js +24 -1
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.d.ts +1 -0
- package/dist/tests/signatureHelp.test.js +73 -0
- package/dist/tests/signatureHelp.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.js +16 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +8 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +5 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +15 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/workspaceMap.d.ts +4 -0
- package/dist/workspaceMap.js +67 -37
- package/dist/workspaceMap.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
@@ -1,17 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
/*
|
3
|
-
* checker.ts
|
4
|
-
* Copyright (c) Microsoft Corporation.
|
5
|
-
* Licensed under the MIT license.
|
6
|
-
* Author: Eric Traut
|
7
|
-
*
|
8
|
-
* A parse tree walker that performs static type checking for
|
9
|
-
* a source file. Most of its work is performed by the type
|
10
|
-
* evaluator, but this module touches every node in the file
|
11
|
-
* to ensure that all statements and expressions are evaluated
|
12
|
-
* and checked. It also performs some additional checks that
|
13
|
-
* cannot (or should not be) performed lazily.
|
14
|
-
*/
|
15
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
16
3
|
if (k2 === undefined) k2 = k;
|
17
4
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
@@ -33,6 +20,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
33
20
|
};
|
34
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
22
|
exports.Checker = void 0;
|
23
|
+
/*
|
24
|
+
* checker.ts
|
25
|
+
* Copyright (c) Microsoft Corporation.
|
26
|
+
* Licensed under the MIT license.
|
27
|
+
* Author: Eric Traut
|
28
|
+
*
|
29
|
+
* A parse tree walker that performs static type checking for
|
30
|
+
* a source file. Most of its work is performed by the type
|
31
|
+
* evaluator, but this module touches every node in the file
|
32
|
+
* to ensure that all statements and expressions are evaluated
|
33
|
+
* and checked. It also performs some additional checks that
|
34
|
+
* cannot (or should not be) performed lazily.
|
35
|
+
*/
|
36
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
36
37
|
const debug_1 = require("../common/debug");
|
37
38
|
const diagnostic_1 = require("../common/diagnostic");
|
38
39
|
const diagnosticRules_1 = require("../common/diagnosticRules");
|
@@ -104,12 +105,13 @@ const deprecatedSpecialForms = new Map([
|
|
104
105
|
// functions to be emitted.
|
105
106
|
const isPrintCodeComplexityEnabled = false;
|
106
107
|
class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
107
|
-
constructor(_importResolver, _evaluator, _parseResults, _sourceMapper) {
|
108
|
+
constructor(_importResolver, _evaluator, _parseResults, _sourceMapper, _dependentFiles) {
|
108
109
|
super();
|
109
110
|
this._importResolver = _importResolver;
|
110
111
|
this._evaluator = _evaluator;
|
111
112
|
this._parseResults = _parseResults;
|
112
113
|
this._sourceMapper = _sourceMapper;
|
114
|
+
this._dependentFiles = _dependentFiles;
|
113
115
|
this._isUnboundCheckSuppressed = false;
|
114
116
|
// A list of all nodes that are defined within the module that
|
115
117
|
// have their own scopes.
|
@@ -764,6 +766,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
764
766
|
this._validateComparisonTypes(node);
|
765
767
|
}
|
766
768
|
}
|
769
|
+
else if (node.operator === 39 /* Is */ || node.operator === 40 /* IsNot */) {
|
770
|
+
// Don't apply this rule if it's within an assert.
|
771
|
+
if (!ParseTreeUtils.isWithinAssertExpression(node)) {
|
772
|
+
this._validateComparisonTypesForIsOperator(node);
|
773
|
+
}
|
774
|
+
}
|
767
775
|
else if (node.operator === 41 /* In */ || node.operator === 42 /* NotIn */) {
|
768
776
|
// Don't apply this rule if it's within an assert.
|
769
777
|
if (!ParseTreeUtils.isWithinAssertExpression(node)) {
|
@@ -1154,6 +1162,36 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1154
1162
|
}), node);
|
1155
1163
|
}
|
1156
1164
|
}
|
1165
|
+
// Determines whether the types of the two operands for an "is" or "is not"
|
1166
|
+
// operation have overlapping types.
|
1167
|
+
_validateComparisonTypesForIsOperator(node) {
|
1168
|
+
const rightType = this._evaluator.getType(node.rightExpression);
|
1169
|
+
if (!rightType || !(0, types_1.isNoneInstance)(rightType)) {
|
1170
|
+
return;
|
1171
|
+
}
|
1172
|
+
const leftType = this._evaluator.getType(node.leftExpression);
|
1173
|
+
if (!leftType) {
|
1174
|
+
return;
|
1175
|
+
}
|
1176
|
+
let foundMatchForNone = false;
|
1177
|
+
(0, typeUtils_1.doForEachSubtype)(leftType, (subtype) => {
|
1178
|
+
subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
1179
|
+
if (this._evaluator.assignType(subtype, types_1.NoneType.createInstance())) {
|
1180
|
+
foundMatchForNone = true;
|
1181
|
+
}
|
1182
|
+
});
|
1183
|
+
const getMessage = () => {
|
1184
|
+
return node.operator === 39 /* Is */
|
1185
|
+
? localize_1.Localizer.Diagnostic.comparisonAlwaysFalse()
|
1186
|
+
: localize_1.Localizer.Diagnostic.comparisonAlwaysTrue();
|
1187
|
+
};
|
1188
|
+
if (!foundMatchForNone) {
|
1189
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
|
1190
|
+
leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
|
1191
|
+
rightType: this._evaluator.printType(rightType),
|
1192
|
+
}), node);
|
1193
|
+
}
|
1194
|
+
}
|
1157
1195
|
// Determines whether the types of the two operands for an == or != operation
|
1158
1196
|
// have overlapping types.
|
1159
1197
|
_validateComparisonTypes(node) {
|
@@ -1732,11 +1770,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1732
1770
|
});
|
1733
1771
|
}
|
1734
1772
|
_validateSymbolTables() {
|
1773
|
+
var _a;
|
1774
|
+
const dependentFileInfo = (_a = this._dependentFiles) === null || _a === void 0 ? void 0 : _a.map((p) => AnalyzerNodeInfo.getFileInfo(p.parseTree));
|
1735
1775
|
for (const scopedNode of this._scopedNodes) {
|
1736
1776
|
const scope = AnalyzerNodeInfo.getScope(scopedNode);
|
1737
1777
|
if (scope) {
|
1738
1778
|
scope.symbolTable.forEach((symbol, name) => {
|
1739
|
-
this._conditionallyReportUnusedSymbol(name, symbol, scope.type);
|
1779
|
+
this._conditionallyReportUnusedSymbol(name, symbol, scope.type, dependentFileInfo);
|
1740
1780
|
this._reportIncompatibleDeclarations(name, symbol);
|
1741
1781
|
this._reportMultipleFinalDeclarations(name, symbol, scope.type);
|
1742
1782
|
this._reportMultipleTypeAliasDeclarations(name, symbol);
|
@@ -2079,11 +2119,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2079
2119
|
}
|
2080
2120
|
}
|
2081
2121
|
}
|
2082
|
-
_conditionallyReportUnusedSymbol(name, symbol, scopeType) {
|
2122
|
+
_conditionallyReportUnusedSymbol(name, symbol, scopeType, dependentFileInfo) {
|
2083
2123
|
const accessedSymbolSet = this._fileInfo.accessedSymbolSet;
|
2084
|
-
if (symbol.isIgnoredForProtocolMatch() ||
|
2085
|
-
|
2086
|
-
|
2124
|
+
if (symbol.isIgnoredForProtocolMatch() || accessedSymbolSet.has(symbol.id)) {
|
2125
|
+
return;
|
2126
|
+
}
|
2127
|
+
// If this file is implicitly imported by other files, we need to make sure the symbol defined in
|
2128
|
+
// the current file is not accessed from those other files.
|
2129
|
+
if (dependentFileInfo && dependentFileInfo.some((i) => i.accessedSymbolSet.has(symbol.id))) {
|
2087
2130
|
return;
|
2088
2131
|
}
|
2089
2132
|
// A name of "_" means "I know this symbol isn't used", so
|
@@ -2650,7 +2693,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2650
2693
|
const stdlibPath = this._importResolver.getTypeshedStdLibPath(this._fileInfo.executionEnvironment);
|
2651
2694
|
if (stdlibPath && this._importResolver.isStdlibModule(module, this._fileInfo.executionEnvironment)) {
|
2652
2695
|
// If the definition for this name is in 'user' module, it is overwriting the stdlib module.
|
2653
|
-
const definitions = definitionProvider_1.DefinitionProvider.getDefinitionsForNode(this._sourceMapper, namePartNodes[namePartNodes.length - 1], definitionProvider_1.DefinitionFilter.All, this._evaluator);
|
2696
|
+
const definitions = definitionProvider_1.DefinitionProvider.getDefinitionsForNode(this._sourceMapper, namePartNodes[namePartNodes.length - 1], definitionProvider_1.DefinitionFilter.All, this._evaluator, vscode_languageserver_1.CancellationToken.None);
|
2654
2697
|
const paths = definitions ? definitions.map((d) => d.path) : [];
|
2655
2698
|
paths.forEach((p) => {
|
2656
2699
|
if (!p.startsWith(stdlibPath) && !(0, sourceMapper_1.isStubFile)(p) && this._sourceMapper.isUserCode(p)) {
|