@zzzen/pyright-internal 1.2.0-dev.20240414 → 1.2.0-dev.20240428
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/analyzerNodeInfo.d.ts +1 -4
- package/dist/analyzer/analyzerNodeInfo.js +1 -11
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.d.ts +0 -2
- package/dist/analyzer/binder.js +42 -66
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +57 -17
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.js +53 -23
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +1 -1
- package/dist/analyzer/dataClasses.js +26 -11
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/deprecatedSymbols.js +2 -4
- package/dist/analyzer/deprecatedSymbols.js.map +1 -1
- package/dist/analyzer/namedTuples.js +0 -8
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +10 -10
- package/dist/analyzer/parseTreeUtils.d.ts +6 -3
- package/dist/analyzer/parseTreeUtils.js +75 -46
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/protocols.js +32 -13
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scope.d.ts +14 -7
- package/dist/analyzer/scope.js +25 -16
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/scopeUtils.js +3 -3
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +0 -2
- package/dist/analyzer/service.js +1 -4
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +3 -1
- package/dist/analyzer/typeEvaluator.js +250 -205
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +5 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +4 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +35 -110
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +5 -3
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +4 -6
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.js +10 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundThreadBase.js +4 -2
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.d.ts +5 -0
- package/dist/commands/dumpFileDebugInfoCommand.js +83 -74
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/console.d.ts +12 -1
- package/dist/common/console.js +22 -3
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.d.ts +5 -0
- package/dist/common/core.js +8 -1
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.d.ts +4 -0
- package/dist/common/diagnostic.js +10 -4
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +2 -2
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +0 -1
- package/dist/common/fileSystem.js +1 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +6 -3
- package/dist/common/languageServerInterface.js +11 -0
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +35 -1
- package/dist/common/realFileSystem.js +4 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/uri/uri.d.ts +4 -0
- package/dist/common/uri/uri.js +11 -4
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +4 -1
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +12 -8
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +1 -1
- package/dist/languageService/referencesProvider.js +3 -2
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +3 -0
- package/dist/localization/localize.js +1 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +3 -0
- package/dist/localization/package.nls.de.json +3 -0
- package/dist/localization/package.nls.en-us.json +1 -0
- package/dist/localization/package.nls.es.json +3 -0
- package/dist/localization/package.nls.fr.json +3 -0
- package/dist/localization/package.nls.it.json +3 -0
- package/dist/localization/package.nls.ja.json +3 -0
- package/dist/localization/package.nls.ko.json +3 -0
- package/dist/localization/package.nls.pl.json +3 -0
- package/dist/localization/package.nls.pt-br.json +3 -0
- package/dist/localization/package.nls.qps-ploc.json +3 -0
- package/dist/localization/package.nls.ru.json +3 -0
- package/dist/localization/package.nls.tr.json +3 -0
- package/dist/localization/package.nls.zh-cn.json +3 -0
- package/dist/localization/package.nls.zh-tw.json +3 -0
- package/dist/parser/parseNodes.d.ts +2 -2
- package/dist/tests/checker.test.js +8 -0
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/config.test.js +11 -0
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/{completions.importDunderNames.fourslash.js → completions.import.dunderNames.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.dunderNames.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.js → completions.import.duplicates.fourslash.js} +1 -1
- package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.js.map → completions.import.duplicates.fourslash.js.map} +1 -1
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.import.exactMatch.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.js +14 -0
- package/dist/tests/fourslash/completions.import.excludeAlreadyImported.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.d.ts +1 -0
- package/dist/tests/fourslash/{completions.importInterimFile.fourslash.disabled.js → completions.import.interimFile.fourslash.disabled.js} +1 -1
- package/dist/tests/fourslash/completions.import.interimFile.fourslash.disabled.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPrivateNoPytyped.fourslash.js → completions.import.privateNoPytyped.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.privateNoPytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPytyped.fourslash.js → completions.import.pytyped.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.pytyped.fourslash.js.map +1 -0
- package/dist/tests/fourslash/{completions.importPytypedLocal.fourslash.js → completions.import.pytypedLocal.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.pytypedLocal.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.import.submodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/{completions.importSubmodule.fourslash.js → completions.import.submodule.fourslash.js} +1 -1
- package/dist/tests/fourslash/completions.import.submodule.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +1 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +2 -1
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +1 -1
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator2.test.js +4 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +5 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +2 -2
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +3 -1
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +0 -1
- package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importPytyped.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js.map +0 -1
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +0 -1
- /package/dist/tests/fourslash/{completions.importDunderNames.fourslash.d.ts → completions.import.dunderNames.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPrivateNoPytyped.fourslash.d.ts → completions.import.duplicates.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importInterimFile.fourslash.disabled.d.ts → completions.import.exactMatch.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importSubmodule.fourslash.d.ts → completions.import.excludeAlreadyImported.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPytyped.fourslash.d.ts → completions.import.privateNoPytyped.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importPytypedLocal.fourslash.d.ts → completions.import.pytyped.fourslash.d.ts} +0 -0
- /package/dist/tests/fourslash/{completions.importsDuplicates.fourslash.d.ts → completions.import.pytypedLocal.fourslash.d.ts} +0 -0
@@ -1,10 +1,9 @@
|
|
1
|
-
import { ClassNode, ExecutionScopeNode, FunctionNode, LambdaNode, ListComprehensionNode, ModuleNode,
|
1
|
+
import { ClassNode, ExecutionScopeNode, FunctionNode, LambdaNode, ListComprehensionNode, ModuleNode, ParseNode, StringNode } from '../parser/parseNodes';
|
2
2
|
import { AnalyzerFileInfo } from './analyzerFileInfo';
|
3
3
|
import { FlowNode } from './codeFlowTypes';
|
4
4
|
import { Declaration } from './declaration';
|
5
5
|
import { ImportResult } from './importResult';
|
6
6
|
import { Scope } from './scope';
|
7
|
-
import { Symbol } from './symbol';
|
8
7
|
export interface DunderAllInfo {
|
9
8
|
names: string[];
|
10
9
|
stringNodes: StringNode[];
|
@@ -30,6 +29,4 @@ export declare function getCodeFlowComplexity(node: ExecutionScopeNode): number;
|
|
30
29
|
export declare function setCodeFlowComplexity(node: ExecutionScopeNode, complexity: number): void;
|
31
30
|
export declare function getDunderAllInfo(node: ModuleNode): DunderAllInfo | undefined;
|
32
31
|
export declare function setDunderAllInfo(node: ModuleNode, names: DunderAllInfo | undefined): void;
|
33
|
-
export declare function getTypeParameterSymbol(node: NameNode): Symbol | undefined;
|
34
|
-
export declare function setTypeParameterSymbol(node: NameNode, symbol: Symbol): void;
|
35
32
|
export declare function isCodeUnreachable(node: ParseNode): boolean;
|
@@ -11,7 +11,7 @@
|
|
11
11
|
* (e.g. hover information).
|
12
12
|
*/
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.isCodeUnreachable = exports.
|
14
|
+
exports.isCodeUnreachable = exports.setDunderAllInfo = exports.getDunderAllInfo = exports.setCodeFlowComplexity = exports.getCodeFlowComplexity = exports.setCodeFlowExpressions = exports.getCodeFlowExpressions = exports.setFileInfo = exports.getFileInfo = exports.setAfterFlowNode = exports.getAfterFlowNode = exports.setFlowNode = exports.getFlowNode = exports.setDeclaration = exports.getDeclaration = exports.setScope = exports.getScope = exports.setImportInfo = exports.getImportInfo = exports.cleanNodeAnalysisInfo = void 0;
|
15
15
|
const codeFlowTypes_1 = require("./codeFlowTypes");
|
16
16
|
// Cleans out all fields that are added by the analyzer phases
|
17
17
|
// (after the post-parse walker).
|
@@ -122,16 +122,6 @@ function setDunderAllInfo(node, names) {
|
|
122
122
|
analyzerNode.dunderAllInfo = names;
|
123
123
|
}
|
124
124
|
exports.setDunderAllInfo = setDunderAllInfo;
|
125
|
-
function getTypeParameterSymbol(node) {
|
126
|
-
const analyzerNode = node;
|
127
|
-
return analyzerNode.typeParameterSymbol;
|
128
|
-
}
|
129
|
-
exports.getTypeParameterSymbol = getTypeParameterSymbol;
|
130
|
-
function setTypeParameterSymbol(node, symbol) {
|
131
|
-
const analyzerNode = node;
|
132
|
-
analyzerNode.typeParameterSymbol = symbol;
|
133
|
-
}
|
134
|
-
exports.setTypeParameterSymbol = setTypeParameterSymbol;
|
135
125
|
function isCodeUnreachable(node) {
|
136
126
|
let curNode = node;
|
137
127
|
// Walk up the parse tree until we find a node with
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"analyzerNodeInfo.js","sourceRoot":"","sources":["../../../../../src/analyzer/analyzerNodeInfo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
1
|
+
{"version":3,"file":"analyzerNodeInfo.js","sourceRoot":"","sources":["../../../../../src/analyzer/analyzerNodeInfo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAcH,mDAAsD;AAwDtD,8DAA8D;AAC9D,iCAAiC;AACjC,SAAgB,qBAAqB,CAAC,IAAe;IACjD,MAAM,YAAY,GAAG,IAAwB,CAAC;IAC9C,OAAO,YAAY,CAAC,KAAK,CAAC;IAC1B,OAAO,YAAY,CAAC,WAAW,CAAC;IAChC,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC7B,OAAO,YAAY,CAAC,aAAa,CAAC;IAClC,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC7B,OAAO,YAAY,CAAC,mBAAmB,CAAC;IACxC,OAAO,YAAY,CAAC,kBAAkB,CAAC;IACvC,OAAO,YAAY,CAAC,aAAa,CAAC;IAClC,OAAO,YAAY,CAAC,mBAAmB,CAAC;AAC5C,CAAC;AAXD,sDAWC;AAED,SAAgB,aAAa,CAAC,IAAe;IACzC,MAAM,YAAY,GAAG,IAAwB,CAAC;IAC9C,OAAO,YAAY,CAAC,UAAU,CAAC;AACnC,CAAC;AAHD,sCAGC;AAED,SAAgB,aAAa,CAAC,IAAe,EAAE,UAAwB;IACnE,MAAM,YAAY,GAAG,IAAwB,CAAC;IAC9C,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;AACzC,CAAC;AAHD,sCAGC;AAED,SAAgB,QAA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AE1C,mDAAmD;IACnD,2BAA2B;IAC3B,OAAO,OAAO,EAAE;QACZ,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,QAAQ,EAAE;YACV,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG,yBAAS,CAAC,WAAW,CAAC,CAAC;SACrD;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;KAC5B;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAdD,8CAcC"}
|
@@ -8,7 +8,6 @@ export declare class Binder extends ParseTreeWalker {
|
|
8
8
|
private _deferredBindingTasks;
|
9
9
|
private _currentScope;
|
10
10
|
private _currentFlowNode;
|
11
|
-
private _activeTypeParams;
|
12
11
|
private _targetFunctionDeclaration;
|
13
12
|
private _currentBreakTarget;
|
14
13
|
private _currentContinueTarget;
|
@@ -79,7 +78,6 @@ export declare class Binder extends ParseTreeWalker {
|
|
79
78
|
visitPatternCapture(node: PatternCaptureNode): boolean;
|
80
79
|
visitPatternMappingExpandEntry(node: PatternMappingExpandEntryNode): boolean;
|
81
80
|
private _formatModuleName;
|
82
|
-
private _removeActiveTypeParameters;
|
83
81
|
private _getNonClassParentScope;
|
84
82
|
private _addSlotsToCurrentScope;
|
85
83
|
private _isInListComprehension;
|
package/dist/analyzer/binder.js
CHANGED
@@ -56,7 +56,6 @@ const docStringUtils_1 = require("./docStringUtils");
|
|
56
56
|
const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
|
57
57
|
const parseTreeWalker_1 = require("./parseTreeWalker");
|
58
58
|
const scope_1 = require("./scope");
|
59
|
-
const scopeUtils_1 = require("./scopeUtils");
|
60
59
|
const StaticExpressions = __importStar(require("./staticExpressions"));
|
61
60
|
const symbol_1 = require("./symbol");
|
62
61
|
const symbolNameUtils_1 = require("./symbolNameUtils");
|
@@ -71,9 +70,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
71
70
|
this._moduleSymbolOnly = _moduleSymbolOnly;
|
72
71
|
// A queue of deferred analysis operations.
|
73
72
|
this._deferredBindingTasks = [];
|
74
|
-
// Tracks the type parameters that are currently active within the
|
75
|
-
// scope and any outer scopes.
|
76
|
-
this._activeTypeParams = new Map();
|
77
73
|
// Flow nodes used within try blocks.
|
78
74
|
this._currentExceptTargets = [];
|
79
75
|
// Flow nodes used within try/finally flows.
|
@@ -115,7 +111,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
115
111
|
// We'll assume that if there is no builtins scope provided, we must be
|
116
112
|
// binding the builtins module itself.
|
117
113
|
const isBuiltInModule = this._fileInfo.builtinsScope === undefined;
|
118
|
-
this._createNewScope(isBuiltInModule ?
|
114
|
+
this._createNewScope(isBuiltInModule ? 5 /* ScopeType.Builtin */ : 4 /* ScopeType.Module */, this._fileInfo.builtinsScope,
|
115
|
+
/* proxyScope */ undefined, () => {
|
119
116
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
120
117
|
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode);
|
121
118
|
// Bind implicit names.
|
@@ -237,11 +234,14 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
237
234
|
}
|
238
235
|
// Stash the declaration in the parse node for later access.
|
239
236
|
AnalyzerNodeInfo.setDeclaration(node, classDeclaration);
|
237
|
+
let typeParamScope;
|
240
238
|
if (node.typeParameters) {
|
241
239
|
this.walk(node.typeParameters);
|
240
|
+
typeParamScope = AnalyzerNodeInfo.getScope(node.typeParameters);
|
242
241
|
}
|
243
242
|
this.walkMultiple(node.arguments);
|
244
|
-
this._createNewScope(
|
243
|
+
this._createNewScope(3 /* ScopeType.Class */, typeParamScope !== null && typeParamScope !== void 0 ? typeParamScope : this._getNonClassParentScope(),
|
244
|
+
/* proxyScope */ undefined, () => {
|
245
245
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
246
246
|
this._addImplicitSymbolToCurrentScope('__doc__', node, 'str | None');
|
247
247
|
this._addImplicitSymbolToCurrentScope('__module__', node, 'str');
|
@@ -257,9 +257,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
257
257
|
this._dunderSlotsEntries = undefined;
|
258
258
|
});
|
259
259
|
this._createAssignmentTargetFlowNodes(node.name, /* walkTargets */ false, /* unbound */ false);
|
260
|
-
if (node.typeParameters) {
|
261
|
-
this._removeActiveTypeParameters(node.typeParameters);
|
262
|
-
}
|
263
260
|
return false;
|
264
261
|
}
|
265
262
|
visitFunction(node) {
|
@@ -288,8 +285,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
288
285
|
this.walk(param.defaultValue);
|
289
286
|
}
|
290
287
|
});
|
288
|
+
let typeParamScope;
|
291
289
|
if (node.typeParameters) {
|
292
290
|
this.walk(node.typeParameters);
|
291
|
+
typeParamScope = AnalyzerNodeInfo.getScope(node.typeParameters);
|
293
292
|
}
|
294
293
|
this.walkMultiple(node.decorators);
|
295
294
|
node.parameters.forEach((param) => {
|
@@ -308,7 +307,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
308
307
|
}
|
309
308
|
// Don't walk the body of the function until we're done analyzing
|
310
309
|
// the current scope.
|
311
|
-
this._createNewScope(
|
310
|
+
this._createNewScope(2 /* ScopeType.Function */, typeParamScope !== null && typeParamScope !== void 0 ? typeParamScope : this._getNonClassParentScope(),
|
311
|
+
/* proxyScope */ undefined, () => {
|
312
312
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
313
313
|
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
314
314
|
if (enclosingClass) {
|
@@ -348,6 +348,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
348
348
|
this._currentReturnTarget = this._createBranchLabel();
|
349
349
|
// Walk the statements that make up the function.
|
350
350
|
this.walk(node.suite);
|
351
|
+
this._targetFunctionDeclaration = undefined;
|
351
352
|
// Associate the code flow node at the end of the suite with
|
352
353
|
// the suite.
|
353
354
|
AnalyzerNodeInfo.setAfterFlowNode(node.suite, this._currentFlowNode);
|
@@ -362,9 +363,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
362
363
|
});
|
363
364
|
});
|
364
365
|
this._createAssignmentTargetFlowNodes(node.name, /* walkTargets */ false, /* unbound */ false);
|
365
|
-
if (node.typeParameters) {
|
366
|
-
this._removeActiveTypeParameters(node.typeParameters);
|
367
|
-
}
|
368
366
|
// We'll walk the child nodes in a deferred manner, so don't walk them now.
|
369
367
|
return false;
|
370
368
|
}
|
@@ -378,7 +376,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
378
376
|
this.walk(param.defaultValue);
|
379
377
|
}
|
380
378
|
});
|
381
|
-
this._createNewScope(
|
379
|
+
this._createNewScope(2 /* ScopeType.Function */, this._getNonClassParentScope(), /* proxyScope */ undefined, () => {
|
382
380
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
383
381
|
this._deferBinding(() => {
|
384
382
|
// Create a start node for the lambda.
|
@@ -437,7 +435,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
437
435
|
}
|
438
436
|
}
|
439
437
|
// Is this an manipulation of dunder all?
|
440
|
-
if (this._currentScope.type ===
|
438
|
+
if (this._currentScope.type === 4 /* ScopeType.Module */ &&
|
441
439
|
node.leftExpression.nodeType === 35 /* ParseNodeType.MemberAccess */ &&
|
442
440
|
node.leftExpression.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
443
441
|
node.leftExpression.leftExpression.value === '__all__') {
|
@@ -503,14 +501,16 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
503
501
|
return false;
|
504
502
|
}
|
505
503
|
visitTypeParameterList(node) {
|
504
|
+
const typeParamScope = new scope_1.Scope(0 /* ScopeType.TypeParameter */, this._getNonClassParentScope(), this._currentScope);
|
506
505
|
node.parameters.forEach((param) => {
|
507
506
|
if (param.boundExpression) {
|
508
507
|
this.walk(param.boundExpression);
|
509
508
|
}
|
510
509
|
});
|
510
|
+
const typeParamsSeen = new Set();
|
511
511
|
node.parameters.forEach((param) => {
|
512
512
|
const name = param.name;
|
513
|
-
const symbol =
|
513
|
+
const symbol = typeParamScope.addSymbol(name.value, 0 /* SymbolFlags.None */);
|
514
514
|
const paramDeclaration = {
|
515
515
|
type: 3 /* DeclarationType.TypeParameter */,
|
516
516
|
node: param,
|
@@ -521,12 +521,11 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
521
521
|
};
|
522
522
|
symbol.addDeclaration(paramDeclaration);
|
523
523
|
AnalyzerNodeInfo.setDeclaration(name, paramDeclaration);
|
524
|
-
|
525
|
-
if (this._activeTypeParams.has(name.value)) {
|
524
|
+
if (typeParamsSeen.has(name.value)) {
|
526
525
|
this._addSyntaxError(localize_1.LocMessage.typeParameterExistingTypeParameter().format({ name: name.value }), name);
|
527
526
|
}
|
528
527
|
else {
|
529
|
-
|
528
|
+
typeParamsSeen.add(name.value);
|
530
529
|
}
|
531
530
|
});
|
532
531
|
node.parameters.forEach((param) => {
|
@@ -534,13 +533,16 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
534
533
|
this.walk(param.defaultExpression);
|
535
534
|
}
|
536
535
|
});
|
536
|
+
AnalyzerNodeInfo.setScope(node, typeParamScope);
|
537
537
|
return false;
|
538
538
|
}
|
539
539
|
visitTypeAlias(node) {
|
540
540
|
this._bindNameToScope(this._currentScope, node.name);
|
541
541
|
this.walk(node.name);
|
542
|
+
let typeParamScope;
|
542
543
|
if (node.typeParameters) {
|
543
544
|
this.walk(node.typeParameters);
|
545
|
+
typeParamScope = AnalyzerNodeInfo.getScope(node.typeParameters);
|
544
546
|
}
|
545
547
|
const typeAliasDeclaration = {
|
546
548
|
type: 4 /* DeclarationType.TypeAlias */,
|
@@ -558,10 +560,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
558
560
|
// Stash the declaration in the parse node for later access.
|
559
561
|
AnalyzerNodeInfo.setDeclaration(node, typeAliasDeclaration);
|
560
562
|
this._createAssignmentTargetFlowNodes(node.name, /* walkTargets */ true, /* unbound */ false);
|
563
|
+
const prevScope = this._currentScope;
|
564
|
+
this._currentScope = typeParamScope !== null && typeParamScope !== void 0 ? typeParamScope : this._currentScope;
|
561
565
|
this.walk(node.expression);
|
562
|
-
|
563
|
-
this._removeActiveTypeParameters(node.typeParameters);
|
564
|
-
}
|
566
|
+
this._currentScope = prevScope;
|
565
567
|
return false;
|
566
568
|
}
|
567
569
|
visitAssignment(node) {
|
@@ -611,7 +613,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
611
613
|
// If we didn't create assignment target flow nodes above, do so now.
|
612
614
|
this._createAssignmentTargetFlowNodes(node.leftExpression, /* walkTargets */ true, /* unbound */ false);
|
613
615
|
// Is this an assignment to dunder all?
|
614
|
-
if (this._currentScope.type ===
|
616
|
+
if (this._currentScope.type === 4 /* ScopeType.Module */) {
|
615
617
|
if ((node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && node.leftExpression.value === '__all__') ||
|
616
618
|
(node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */ &&
|
617
619
|
node.leftExpression.valueExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
@@ -655,7 +657,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
655
657
|
}
|
656
658
|
}
|
657
659
|
// Is this an assignment to dunder slots?
|
658
|
-
if (this._currentScope.type ===
|
660
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */) {
|
659
661
|
if ((node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && node.leftExpression.value === '__slots__') ||
|
660
662
|
(node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */ &&
|
661
663
|
node.leftExpression.valueExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
@@ -744,7 +746,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
744
746
|
// Is this an assignment to dunder all of the form
|
745
747
|
// __all__ += <expression>?
|
746
748
|
if (node.operator === 1 /* OperatorType.AddEqual */ &&
|
747
|
-
this._currentScope.type ===
|
749
|
+
this._currentScope.type === 4 /* ScopeType.Module */ &&
|
748
750
|
node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ &&
|
749
751
|
node.leftExpression.value === '__all__') {
|
750
752
|
const expr = node.rightExpression;
|
@@ -917,19 +919,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
917
919
|
}
|
918
920
|
visitName(node) {
|
919
921
|
AnalyzerNodeInfo.setFlowNode(node, this._currentFlowNode);
|
920
|
-
const typeParamSymbol = this._activeTypeParams.get(node.value);
|
921
|
-
if (typeParamSymbol) {
|
922
|
-
const bindingType = this._currentScope.getBindingType(node.value);
|
923
|
-
if (bindingType !== 1 /* NameBindingType.Global */) {
|
924
|
-
// See if the type parameter symbol has been shadowed by a
|
925
|
-
// variable within an inner scope.
|
926
|
-
const nameSymbolWithScope = this._currentScope.lookUpSymbolRecursive(node.value);
|
927
|
-
if (!nameSymbolWithScope || !(0, scopeUtils_1.isScopeContainedWithin)(nameSymbolWithScope.scope, typeParamSymbol.scope)) {
|
928
|
-
AnalyzerNodeInfo.setTypeParameterSymbol(node, typeParamSymbol.symbol);
|
929
|
-
}
|
930
|
-
}
|
931
|
-
}
|
932
|
-
// Name nodes have no children.
|
933
922
|
return false;
|
934
923
|
}
|
935
924
|
visitIndex(node) {
|
@@ -1274,7 +1263,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1274
1263
|
}
|
1275
1264
|
const symbol = this._bindNameToScope(this._currentScope, symbolNameNode);
|
1276
1265
|
if (symbol &&
|
1277
|
-
(this._currentScope.type ===
|
1266
|
+
(this._currentScope.type === 4 /* ScopeType.Module */ || this._currentScope.type === 5 /* ScopeType.Builtin */) &&
|
1278
1267
|
(!node.alias ||
|
1279
1268
|
node.module.nameParts.length !== 1 ||
|
1280
1269
|
node.module.nameParts[0].value !== node.alias.value)) {
|
@@ -1440,8 +1429,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1440
1429
|
// All import statements of the form `from . import x` treat x
|
1441
1430
|
// as an externally-visible (not hidden) symbol.
|
1442
1431
|
if (node.module.nameParts.length > 0) {
|
1443
|
-
if (this._currentScope.type ===
|
1444
|
-
this._currentScope.type ===
|
1432
|
+
if (this._currentScope.type === 4 /* ScopeType.Module */ ||
|
1433
|
+
this._currentScope.type === 5 /* ScopeType.Builtin */) {
|
1445
1434
|
if (!importSymbolNode.alias ||
|
1446
1435
|
importSymbolNode.alias.value !== importSymbolNode.name.value) {
|
1447
1436
|
if (this._fileInfo.isStubFile || this._fileInfo.isInPyTypedPackage) {
|
@@ -1655,7 +1644,8 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1655
1644
|
if (node.forIfNodes.length > 0 && node.forIfNodes[0].nodeType === 33 /* ParseNodeType.ListComprehensionFor */) {
|
1656
1645
|
this.walk(node.forIfNodes[0].iterableExpression);
|
1657
1646
|
}
|
1658
|
-
this._createNewScope(
|
1647
|
+
this._createNewScope(1 /* ScopeType.ListComprehension */, this._getNonClassParentScope(),
|
1648
|
+
/* proxyScope */ undefined, () => {
|
1659
1649
|
var _a;
|
1660
1650
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
1661
1651
|
const falseLabel = this._createBranchLabel();
|
@@ -1808,29 +1798,17 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1808
1798
|
_formatModuleName(node) {
|
1809
1799
|
return '.'.repeat(node.leadingDots) + node.nameParts.map((part) => part.value).join('.');
|
1810
1800
|
}
|
1811
|
-
_removeActiveTypeParameters(node) {
|
1812
|
-
node.parameters.forEach((typeParamNode) => {
|
1813
|
-
const entry = this._activeTypeParams.get(typeParamNode.name.value);
|
1814
|
-
if (entry) {
|
1815
|
-
const decls = entry.symbol.getDeclarations();
|
1816
|
-
(0, debug_1.assert)(decls && decls.length === 1 && decls[0].type === 3 /* DeclarationType.TypeParameter */);
|
1817
|
-
if (decls[0].node === typeParamNode) {
|
1818
|
-
this._activeTypeParams.delete(typeParamNode.name.value);
|
1819
|
-
}
|
1820
|
-
}
|
1821
|
-
});
|
1822
|
-
}
|
1823
1801
|
_getNonClassParentScope() {
|
1824
1802
|
// We may not be able to use the current scope if it's a class scope.
|
1825
1803
|
// Walk up until we find a non-class scope instead.
|
1826
1804
|
let parentScope = this._currentScope;
|
1827
|
-
while (parentScope.type ===
|
1805
|
+
while (parentScope.type === 3 /* ScopeType.Class */) {
|
1828
1806
|
parentScope = parentScope.parent;
|
1829
1807
|
}
|
1830
1808
|
return parentScope;
|
1831
1809
|
}
|
1832
1810
|
_addSlotsToCurrentScope(slotNameNodes) {
|
1833
|
-
(0, debug_1.assert)(this._currentScope.type ===
|
1811
|
+
(0, debug_1.assert)(this._currentScope.type === 3 /* ScopeType.Class */);
|
1834
1812
|
let slotsContainsDict = false;
|
1835
1813
|
for (const slotNameNode of slotNameNodes) {
|
1836
1814
|
const slotName = slotNameNode.strings[0].value;
|
@@ -2662,14 +2640,14 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2662
2640
|
let symbol = scope.lookUpSymbol(name);
|
2663
2641
|
if (!symbol) {
|
2664
2642
|
symbol = scope.addSymbol(name, 1 /* SymbolFlags.InitiallyUnbound */ | 4 /* SymbolFlags.ClassMember */);
|
2665
|
-
if (this._currentScope.type ===
|
2643
|
+
if (this._currentScope.type === 4 /* ScopeType.Module */ || this._currentScope.type === 5 /* ScopeType.Builtin */) {
|
2666
2644
|
if ((0, symbolNameUtils_1.isPrivateOrProtectedName)(name)) {
|
2667
2645
|
if ((0, symbolNameUtils_1.isPrivateName)(name)) {
|
2668
2646
|
// Private names are obscured, so they are always externally hidden.
|
2669
2647
|
symbol.setIsExternallyHidden();
|
2670
2648
|
}
|
2671
2649
|
else if (this._fileInfo.isStubFile || this._fileInfo.isInPyTypedPackage) {
|
2672
|
-
if (this._currentScope.type ===
|
2650
|
+
if (this._currentScope.type === 5 /* ScopeType.Builtin */) {
|
2673
2651
|
// Don't include private-named symbols in the builtin scope.
|
2674
2652
|
symbol.setIsExternallyHidden();
|
2675
2653
|
}
|
@@ -2741,7 +2719,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2741
2719
|
if (isInitiallyUnbound) {
|
2742
2720
|
symbolFlags |= 1 /* SymbolFlags.InitiallyUnbound */;
|
2743
2721
|
}
|
2744
|
-
if (this._currentScope.type ===
|
2722
|
+
if (this._currentScope.type === 3 /* ScopeType.Class */) {
|
2745
2723
|
symbolFlags |= 4 /* SymbolFlags.ClassMember */;
|
2746
2724
|
}
|
2747
2725
|
if (this._fileInfo.isStubFile && (0, symbolNameUtils_1.isPrivateOrProtectedName)(nameValue)) {
|
@@ -2753,12 +2731,12 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
2753
2731
|
}
|
2754
2732
|
return symbol;
|
2755
2733
|
}
|
2756
|
-
_createNewScope(scopeType, parentScope, callback) {
|
2734
|
+
_createNewScope(scopeType, parentScope, proxyScope, callback) {
|
2757
2735
|
const prevScope = this._currentScope;
|
2758
|
-
const newScope = new scope_1.Scope(scopeType, parentScope);
|
2736
|
+
const newScope = new scope_1.Scope(scopeType, parentScope, proxyScope);
|
2759
2737
|
this._currentScope = newScope;
|
2760
2738
|
// If this scope is an execution scope, allocate a new reference map.
|
2761
|
-
const isExecutionScope = scopeType ===
|
2739
|
+
const isExecutionScope = scopeType === 5 /* ScopeType.Builtin */ || scopeType === 4 /* ScopeType.Module */ || scopeType === 2 /* ScopeType.Function */;
|
2762
2740
|
const prevExpressions = this._currentScopeCodeFlowExpressions;
|
2763
2741
|
if (isExecutionScope) {
|
2764
2742
|
this._currentScopeCodeFlowExpressions = new Set();
|
@@ -3256,7 +3234,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3256
3234
|
this._deferredBindingTasks.push({
|
3257
3235
|
scope: this._currentScope,
|
3258
3236
|
codeFlowExpressions: this._currentScopeCodeFlowExpressions,
|
3259
|
-
activeTypeParams: new Map(this._activeTypeParams),
|
3260
3237
|
callback,
|
3261
3238
|
});
|
3262
3239
|
}
|
@@ -3266,7 +3243,6 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3266
3243
|
// Reset the state
|
3267
3244
|
this._currentScope = nextItem.scope;
|
3268
3245
|
this._currentScopeCodeFlowExpressions = nextItem.codeFlowExpressions;
|
3269
|
-
this._activeTypeParams = nextItem.activeTypeParams;
|
3270
3246
|
nextItem.callback();
|
3271
3247
|
}
|
3272
3248
|
}
|
@@ -3371,7 +3347,7 @@ class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
3371
3347
|
this._currentScope = currentScope;
|
3372
3348
|
}
|
3373
3349
|
visitClass(node) {
|
3374
|
-
const newScope = this._createNewScope(
|
3350
|
+
const newScope = this._createNewScope(3 /* ScopeType.Class */, () => {
|
3375
3351
|
this.walk(node.suite);
|
3376
3352
|
});
|
3377
3353
|
if (!AnalyzerNodeInfo.getScope(node)) {
|
@@ -3380,7 +3356,7 @@ class DummyScopeGenerator extends parseTreeWalker_1.ParseTreeWalker {
|
|
3380
3356
|
return false;
|
3381
3357
|
}
|
3382
3358
|
visitFunction(node) {
|
3383
|
-
const newScope = this._createNewScope(
|
3359
|
+
const newScope = this._createNewScope(2 /* ScopeType.Function */, () => {
|
3384
3360
|
this.walk(node.suite);
|
3385
3361
|
});
|
3386
3362
|
if (!AnalyzerNodeInfo.getScope(node)) {
|