mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-16 03:10:35 +03:00
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:
parent
687fadef75
commit
f22576f0f8
@ -6958,7 +6958,7 @@ export class Checker extends ParseTreeWalker {
|
|||||||
typeVars.some((typeVar) => typeVar.scopeId === functionType.details.methodClass?.details.typeVarScopeId)
|
typeVars.some((typeVar) => typeVar.scopeId === functionType.details.methodClass?.details.typeVarScopeId)
|
||||||
) {
|
) {
|
||||||
this._evaluator.addDiagnostic(
|
this._evaluator.addDiagnostic(
|
||||||
DiagnosticRule.reportGeneralTypeIssues,
|
DiagnosticRule.reportInvalidTypeVarUse,
|
||||||
LocMessage.initMethodSelfParamTypeVar(),
|
LocMessage.initMethodSelfParamTypeVar(),
|
||||||
paramInfo.typeAnnotation
|
paramInfo.typeAnnotation
|
||||||
);
|
);
|
||||||
|
@ -1536,7 +1536,7 @@ test('Constructor5', () => {
|
|||||||
test('Constructor6', () => {
|
test('Constructor6', () => {
|
||||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['constructor6.py']);
|
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['constructor6.py']);
|
||||||
|
|
||||||
TestUtils.validateResults(analysisResults, 1);
|
TestUtils.validateResults(analysisResults, 0, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Constructor7', () => {
|
test('Constructor7', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user