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. https://github.com/python/typeshed/pull/11780#issuecomment-2070101577

This commit is contained in:
Eric Traut 2024-04-22 09:45:56 -07:00
parent 687fadef75
commit f22576f0f8
2 changed files with 2 additions and 2 deletions

View File

@ -6958,7 +6958,7 @@ export class Checker extends ParseTreeWalker {
typeVars.some((typeVar) => typeVar.scopeId === functionType.details.methodClass?.details.typeVarScopeId)
) {
this._evaluator.addDiagnostic(
DiagnosticRule.reportGeneralTypeIssues,
DiagnosticRule.reportInvalidTypeVarUse,
LocMessage.initMethodSelfParamTypeVar(),
paramInfo.typeAnnotation
);

View File

@ -1536,7 +1536,7 @@ test('Constructor5', () => {
test('Constructor6', () => {
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['constructor6.py']);
TestUtils.validateResults(analysisResults, 1);
TestUtils.validateResults(analysisResults, 0, 1);
});
test('Constructor7', () => {