@zzzen/pyright-internal 1.2.0-dev.20241103 → 1.2.0-dev.20241110
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/binder.d.ts +1 -0
- package/dist/analyzer/binder.js +35 -12
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +2 -2
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/dataClasses.js +0 -4
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +5 -5
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/operations.js +6 -0
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/patternMatching.js +3 -1
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/service.js +1 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/serviceUtils.d.ts +0 -2
- package/dist/analyzer/serviceUtils.js +3 -5
- package/dist/analyzer/serviceUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +45 -12
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
- package/dist/analyzer/typeUtils.js +9 -7
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/common/pathConsts.d.ts +3 -0
- package/dist/common/pathConsts.js +4 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +6 -2
- package/dist/languageService/autoImporter.js +15 -15
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/completionProvider.js +3 -1
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +2 -2
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +21 -13
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +5 -4
- package/dist/localization/localize.js +5 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +1 -2
- package/dist/localization/package.nls.de.json +2 -3
- package/dist/localization/package.nls.en-us.json +19 -4
- package/dist/localization/package.nls.es.json +2 -3
- package/dist/localization/package.nls.fr.json +1 -2
- package/dist/localization/package.nls.it.json +2 -3
- package/dist/localization/package.nls.ja.json +1 -2
- package/dist/localization/package.nls.ko.json +1 -2
- package/dist/localization/package.nls.pl.json +1 -2
- package/dist/localization/package.nls.pt-br.json +1 -2
- package/dist/localization/package.nls.qps-ploc.json +1 -2
- package/dist/localization/package.nls.ru.json +1 -2
- package/dist/localization/package.nls.tr.json +1 -2
- package/dist/localization/package.nls.zh-cn.json +1 -2
- package/dist/localization/package.nls.zh-tw.json +1 -2
- package/dist/parser/parseNodes.d.ts +3 -2
- package/dist/parser/parseNodes.js +2 -1
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +2 -1
- package/dist/parser/parser.js +36 -7
- package/dist/parser/parser.js.map +1 -1
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.js +73 -0
- package/dist/tests/fourslash/signature.dataclassAlias.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +14 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/testStateUtils.js +2 -2
- package/dist/tests/harness/fourslash/testStateUtils.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 +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator6.test.js +11 -1
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +3 -3
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/package.json +1 -1
@@ -17,6 +17,7 @@ export declare class Binder extends ParseTreeWalker {
|
|
17
17
|
private _finallyTargets;
|
18
18
|
private _currentReturnTarget;
|
19
19
|
private _currentScopeCodeFlowExpressions;
|
20
|
+
private _currentMatchSubjExpr;
|
20
21
|
private _typingImportAliases;
|
21
22
|
private _sysImportAliases;
|
22
23
|
private _dataclassesImportAliases;
|
package/dist/analyzer/binder.js
CHANGED
@@ -1169,19 +1169,23 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1169
1169
|
return false;
|
1170
1170
|
}
|
1171
1171
|
visitAwait(node) {
|
1172
|
-
var _a;
|
1172
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
1173
1173
|
// Make sure this is within an async lambda or function.
|
1174
|
-
const
|
1175
|
-
if (
|
1176
|
-
if (this._fileInfo.ipythonMode &&
|
1174
|
+
const execScopeNode = ParseTreeUtils.getExecutionScopeNode(node);
|
1175
|
+
if ((execScopeNode === null || execScopeNode === void 0 ? void 0 : execScopeNode.nodeType) !== 31 /* ParseNodeType.Function */ || !execScopeNode.d.isAsync) {
|
1176
|
+
if (this._fileInfo.ipythonMode && (execScopeNode === null || execScopeNode === void 0 ? void 0 : execScopeNode.nodeType) === 36 /* ParseNodeType.Module */) {
|
1177
1177
|
// Top level await is allowed in ipython mode.
|
1178
1178
|
return true;
|
1179
1179
|
}
|
1180
|
+
const isInGenerator = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 11 /* ParseNodeType.Comprehension */ &&
|
1181
|
+
((_c = (_b = node.parent) === null || _b === void 0 ? void 0 : _b.parent) === null || _c === void 0 ? void 0 : _c.nodeType) !== 34 /* ParseNodeType.List */ &&
|
1182
|
+
((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.nodeType) !== 45 /* ParseNodeType.Set */ &&
|
1183
|
+
((_g = (_f = node.parent) === null || _f === void 0 ? void 0 : _f.parent) === null || _g === void 0 ? void 0 : _g.nodeType) !== 18 /* ParseNodeType.Dictionary */;
|
1180
1184
|
// Allow if it's within a generator expression. Execution of
|
1181
1185
|
// generator expressions is deferred and therefore can be
|
1182
1186
|
// run within the context of an async function later.
|
1183
|
-
if (
|
1184
|
-
this._addSyntaxError(localize_1.LocMessage.awaitNotInAsync(), node);
|
1187
|
+
if (!isInGenerator) {
|
1188
|
+
this._addSyntaxError(localize_1.LocMessage.awaitNotInAsync(), node.d.awaitToken);
|
1185
1189
|
}
|
1186
1190
|
}
|
1187
1191
|
return true;
|
@@ -1642,7 +1646,7 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1642
1646
|
}
|
1643
1647
|
this._createNewScope(1 /* ScopeType.Comprehension */, this._getNonClassParentScope(),
|
1644
1648
|
/* proxyScope */ undefined, () => {
|
1645
|
-
var _a;
|
1649
|
+
var _a, _b, _c;
|
1646
1650
|
AnalyzerNodeInfo.setScope(node, this._currentScope);
|
1647
1651
|
const falseLabel = this._createBranchLabel();
|
1648
1652
|
// We'll walk the forIfNodes list twice. The first time we'll
|
@@ -1661,7 +1665,9 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1661
1665
|
// Allow if it's within a generator expression. Execution of
|
1662
1666
|
// generator expressions is deferred and therefore can be
|
1663
1667
|
// run within the context of an async function later.
|
1664
|
-
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 34 /* ParseNodeType.List */
|
1668
|
+
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 34 /* ParseNodeType.List */ ||
|
1669
|
+
((_b = node.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 45 /* ParseNodeType.Set */ ||
|
1670
|
+
((_c = node.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 18 /* ParseNodeType.Dictionary */) {
|
1665
1671
|
this._addSyntaxError(localize_1.LocMessage.asyncNotInAsyncFunction(), compr.d.asyncToken);
|
1666
1672
|
}
|
1667
1673
|
}
|
@@ -1730,9 +1736,18 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1730
1736
|
foundIrrefutableCase = true;
|
1731
1737
|
}
|
1732
1738
|
this._currentFlowNode = this._finishFlowLabel(preGuardLabel);
|
1739
|
+
// Note the active match subject expression prior to binding
|
1740
|
+
// the pattern. If the pattern involves any targets that overwrite
|
1741
|
+
// the subject expression, this will be set to undefined.
|
1742
|
+
this._currentMatchSubjExpr = node.d.expr;
|
1733
1743
|
// Bind the pattern.
|
1734
1744
|
this.walk(caseStatement.d.pattern);
|
1735
|
-
|
1745
|
+
// If the pattern involves targets that overwrite the subject
|
1746
|
+
// expression, skip creating a flow node for narrowing the subject.
|
1747
|
+
if (this._currentMatchSubjExpr) {
|
1748
|
+
this._createFlowNarrowForPattern(node.d.expr, caseStatement);
|
1749
|
+
this._currentMatchSubjExpr = undefined;
|
1750
|
+
}
|
1736
1751
|
// Apply the guard expression.
|
1737
1752
|
if (caseStatement.d.guardExpr) {
|
1738
1753
|
this._bindConditional(caseStatement.d.guardExpr, preSuiteLabel, postCaseLabel);
|
@@ -1884,6 +1899,13 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
1884
1899
|
_addPatternCaptureTarget(target) {
|
1885
1900
|
const symbol = this._bindNameToScope(this._currentScope, target);
|
1886
1901
|
this._createAssignmentTargetFlowNodes(target, /* walkTargets */ false, /* unbound */ false);
|
1902
|
+
// See if the target overwrites all or a portion of the subject expression.
|
1903
|
+
if (this._currentMatchSubjExpr) {
|
1904
|
+
if (ParseTreeUtils.isMatchingExpression(target, this._currentMatchSubjExpr) ||
|
1905
|
+
ParseTreeUtils.isPartialMatchingExpression(target, this._currentMatchSubjExpr)) {
|
1906
|
+
this._currentMatchSubjExpr = undefined;
|
1907
|
+
}
|
1908
|
+
}
|
1887
1909
|
if (symbol) {
|
1888
1910
|
const declaration = {
|
1889
1911
|
type: 1 /* DeclarationType.Variable */,
|
@@ -3169,9 +3191,10 @@ class Binder extends parseTreeWalker_1.ParseTreeWalker {
|
|
3169
3191
|
// To determine whether the first parameter of the method
|
3170
3192
|
// refers to the class or the instance, we need to apply
|
3171
3193
|
// some heuristics.
|
3172
|
-
|
3173
|
-
|
3174
|
-
//
|
3194
|
+
const implicitClassMethods = ['__new__', '__init_subclass__', '__class_getitem__'];
|
3195
|
+
if (implicitClassMethods.includes(methodNode.d.name.d.value)) {
|
3196
|
+
// Several methods are special. They act as class methods even
|
3197
|
+
// though they don't have a @classmethod decorator.
|
3175
3198
|
isInstanceMember = false;
|
3176
3199
|
}
|
3177
3200
|
else {
|