@zzzen/pyright-internal 1.2.0-dev.20250202 → 1.2.0-dev.20250209
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.js +1 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +23 -5
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +2 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/parameterUtils.d.ts +4 -1
- package/dist/analyzer/parameterUtils.js +7 -3
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +111 -80
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +2 -1
- package/dist/analyzer/typeUtils.js +8 -2
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +25 -10
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/localization/localize.d.ts +4 -1
- package/dist/localization/localize.js +2 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +7 -3
- package/dist/parser/parser.js +6 -3
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +9 -7
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.js +2 -1
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.async.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.async.fourslash.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator2.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +2 -2
- package/dist/tests/typeEvaluator5.test.js +3 -3
- package/dist/tests/typeEvaluator6.test.js +2 -2
- package/dist/tests/typeEvaluator7.test.js +5 -1
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
@@ -475,7 +475,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
475
475
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.LocMessage.unusedCallResult().format({
|
476
476
|
type: this._evaluator.printType(returnType),
|
477
477
|
}), node);
|
478
|
-
if ((0, types_1.isClassInstance)(returnType) &&
|
478
|
+
if ((0, types_1.isClassInstance)(returnType) &&
|
479
|
+
types_1.ClassType.isBuiltIn(returnType, ['Coroutine', 'CoroutineType'])) {
|
479
480
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedCoroutine, localize_1.LocMessage.unusedCoroutine(), node);
|
480
481
|
}
|
481
482
|
}
|
@@ -643,7 +644,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
643
644
|
const yieldFromType = this._evaluator.getType(node.d.expr) || types_1.UnknownType.create();
|
644
645
|
let yieldType;
|
645
646
|
let sendType;
|
646
|
-
if ((0, types_1.isClassInstance)(yieldFromType) && types_1.ClassType.isBuiltIn(yieldFromType, 'Coroutine')) {
|
647
|
+
if ((0, types_1.isClassInstance)(yieldFromType) && types_1.ClassType.isBuiltIn(yieldFromType, ['Coroutine', 'CoroutineType'])) {
|
647
648
|
// Handle the case of old-style (pre-await) coroutines.
|
648
649
|
yieldType = types_1.UnknownType.create();
|
649
650
|
}
|
@@ -911,6 +912,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
911
912
|
node.d.targets.forEach((name) => {
|
912
913
|
this._evaluator.getType(name);
|
913
914
|
this.walk(name);
|
915
|
+
this._validateNonlocalTypeParam(name);
|
914
916
|
});
|
915
917
|
});
|
916
918
|
return false;
|
@@ -1188,7 +1190,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1188
1190
|
if (!(0, types_1.isFunction)(subtype) && !(0, types_1.isOverloaded)(subtype)) {
|
1189
1191
|
isExprFunction = false;
|
1190
1192
|
}
|
1191
|
-
if (!(0, types_1.isClassInstance)(subtype) || !types_1.ClassType.isBuiltIn(subtype, 'Coroutine')) {
|
1193
|
+
if (!(0, types_1.isClassInstance)(subtype) || !types_1.ClassType.isBuiltIn(subtype, ['Coroutine', 'CoroutineType'])) {
|
1192
1194
|
isCoroutine = false;
|
1193
1195
|
}
|
1194
1196
|
});
|
@@ -1237,6 +1239,16 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1237
1239
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedExpression, localize_1.LocMessage.unusedExpression(), node);
|
1238
1240
|
}
|
1239
1241
|
}
|
1242
|
+
// Verifies that the target of a nonlocal statement is not a PEP 695-style
|
1243
|
+
// TypeParameter. This situation results in a runtime exception.
|
1244
|
+
_validateNonlocalTypeParam(node) {
|
1245
|
+
// Look up the symbol to see if it's a type parameter.
|
1246
|
+
const symbolWithScope = this._evaluator.lookUpSymbolRecursive(node, node.d.value, /* honorCodeFlow */ false);
|
1247
|
+
if (!symbolWithScope || symbolWithScope.scope.type !== 0 /* ScopeType.TypeParameter */) {
|
1248
|
+
return;
|
1249
|
+
}
|
1250
|
+
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.nonlocalTypeParam().format({ name: node.d.value }), node);
|
1251
|
+
}
|
1240
1252
|
_validateExhaustiveMatch(node) {
|
1241
1253
|
// This check can be expensive, so skip it if it's disabled.
|
1242
1254
|
if (this._fileInfo.diagnosticRuleSet.reportMatchNotExhaustive === 'none') {
|
@@ -2113,6 +2125,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2113
2125
|
implementation = type;
|
2114
2126
|
}
|
2115
2127
|
if (!implementation) {
|
2128
|
+
// If this is a method within a protocol class, don't require that
|
2129
|
+
// there is an implementation.
|
2116
2130
|
const containingClassNode = ParseTreeUtils.getEnclosingClassOrFunction(primaryDecl.node);
|
2117
2131
|
if (containingClassNode && containingClassNode.nodeType === 10 /* ParseNodeType.Class */) {
|
2118
2132
|
const classType = this._evaluator.getTypeOfClass(containingClassNode);
|
@@ -2128,8 +2142,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2128
2142
|
}
|
2129
2143
|
}
|
2130
2144
|
}
|
2131
|
-
// If
|
2132
|
-
//
|
2145
|
+
// If the declaration isn't associated with any of the overloads in the
|
2146
|
+
// type, the overloads came from a decorator that captured the overload
|
2147
|
+
// from somewhere else.
|
2148
|
+
if (!overloads.find((overload) => overload.shared.declaration === primaryDecl)) {
|
2149
|
+
return;
|
2150
|
+
}
|
2133
2151
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportNoOverloadImplementation, localize_1.LocMessage.overloadWithoutImplementation().format({
|
2134
2152
|
name: primaryDecl.node.d.name.d.value,
|
2135
2153
|
}), primaryDecl.node.d.name);
|