Skip to content

Commit f22576f

Browse files
committed
Moved check for invalid use of class-scoped TypeVar within a self annotation in __init__. It was previously reported under reportGeneralTypeIssues, but it's now moved to reportInvalidTypeVarUse. This was done to help typeshed maintainers migrate away from this pattern. python/typeshed#11780 (comment)
1 parent 687fade commit f22576f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/pyright-internal/src/analyzer/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6958,7 +6958,7 @@ export class Checker extends ParseTreeWalker {
69586958
typeVars.some((typeVar) => typeVar.scopeId === functionType.details.methodClass?.details.typeVarScopeId)
69596959
) {
69606960
this._evaluator.addDiagnostic(
6961-
DiagnosticRule.reportGeneralTypeIssues,
6961+
DiagnosticRule.reportInvalidTypeVarUse,
69626962
LocMessage.initMethodSelfParamTypeVar(),
69636963
paramInfo.typeAnnotation
69646964
);

packages/pyright-internal/src/tests/typeEvaluator3.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ test('Constructor5', () => {
15361536
test('Constructor6', () => {
15371537
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['constructor6.py']);
15381538

1539-
TestUtils.validateResults(analysisResults, 1);
1539+
TestUtils.validateResults(analysisResults, 0, 1);
15401540
});
15411541

15421542
test('Constructor7', () => {

0 commit comments

Comments
 (0)