@zzzen/pyright-internal 1.2.0-dev.20260802 → 1.2.0-dev.20260809
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 +4 -1
- package/dist/analyzer/analyzerNodeInfo.js +13 -0
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.js +1 -0
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +34 -15
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +12 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
|
@@ -3247,30 +3247,49 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
|
3247
3247
|
}
|
|
3248
3248
|
});
|
|
3249
3249
|
}
|
|
3250
|
-
// Verifies the rules specified
|
|
3251
|
-
// They cannot have statements other than type annotations, doc
|
|
3252
|
-
//
|
|
3250
|
+
// Verifies the rules specified for TypedDict class bodies.
|
|
3251
|
+
// They cannot have statements other than type annotations, doc strings,
|
|
3252
|
+
// "pass" statements, ellipses, and statically evaluable if statements.
|
|
3253
3253
|
_validateTypedDictClassSuite(suiteNode) {
|
|
3254
3254
|
const emitBadStatementError = (node) => {
|
|
3255
3255
|
this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictBadVar(), node);
|
|
3256
3256
|
};
|
|
3257
|
-
|
|
3258
|
-
if (
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3257
|
+
function validateStatement(statement) {
|
|
3258
|
+
if (AnalyzerNodeInfo.isCodeUnreachable(statement)) {
|
|
3259
|
+
return;
|
|
3260
|
+
}
|
|
3261
|
+
if (statement.nodeType === 47 /* ParseNodeType.StatementList */) {
|
|
3262
|
+
for (const substatement of statement.d.statements) {
|
|
3263
|
+
if (substatement.nodeType !== 54 /* ParseNodeType.TypeAnnotation */ &&
|
|
3264
|
+
substatement.nodeType !== 21 /* ParseNodeType.Ellipsis */ &&
|
|
3265
|
+
substatement.nodeType !== 48 /* ParseNodeType.StringList */ &&
|
|
3266
|
+
substatement.nodeType !== 42 /* ParseNodeType.Pass */) {
|
|
3267
|
+
emitBadStatementError(substatement);
|
|
3267
3268
|
}
|
|
3268
3269
|
}
|
|
3269
|
-
|
|
3270
|
+
return;
|
|
3271
|
+
}
|
|
3272
|
+
if (statement.nodeType === 22 /* ParseNodeType.If */) {
|
|
3273
|
+
const conditionValue = AnalyzerNodeInfo.getStaticConditionValue(statement);
|
|
3274
|
+
if (conditionValue === undefined) {
|
|
3270
3275
|
emitBadStatementError(statement);
|
|
3276
|
+
return;
|
|
3277
|
+
}
|
|
3278
|
+
const reachableSuite = conditionValue ? statement.d.ifSuite : statement.d.elseSuite;
|
|
3279
|
+
if (reachableSuite?.nodeType === 22 /* ParseNodeType.If */) {
|
|
3280
|
+
validateStatement(reachableSuite);
|
|
3271
3281
|
}
|
|
3282
|
+
else if (reachableSuite) {
|
|
3283
|
+
validateSuite(reachableSuite);
|
|
3284
|
+
}
|
|
3285
|
+
return;
|
|
3272
3286
|
}
|
|
3273
|
-
|
|
3287
|
+
emitBadStatementError(statement);
|
|
3288
|
+
}
|
|
3289
|
+
function validateSuite(suite) {
|
|
3290
|
+
suite.d.statements.forEach((statement) => validateStatement(statement));
|
|
3291
|
+
}
|
|
3292
|
+
validateSuite(suiteNode);
|
|
3274
3293
|
}
|
|
3275
3294
|
_validateTypeGuardFunction(node, functionType, isMethod) {
|
|
3276
3295
|
const returnType = functionType.shared.declaredReturnType;
|