Fixed bug that resulted in false positive error when using a member access expression within a list of base classes in a class declaration statement.

This commit is contained in:
Eric Traut 2022-05-05 16:15:34 -07:00
parent 28c431ef33
commit 648ae44bfe
2 changed files with 25 additions and 3 deletions

View File

@ -3926,7 +3926,12 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
}
}
if (isTypeVar(type) && (flags & EvaluatorFlags.ExpectingType) === 0 && type.details.name === name) {
if (
isTypeVar(type) &&
!type.details.isParamSpec &&
(flags & EvaluatorFlags.ExpectingType) === 0 &&
type.details.name === name
) {
// Handle the special case of a PEP 604 union. These can appear within
// an implied type alias where we are not expecting a type.
const isPep604Union =
@ -4332,8 +4337,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
const baseTypeFlags =
EvaluatorFlags.DoNotSpecialize |
(flags &
(EvaluatorFlags.ExpectingType |
EvaluatorFlags.ExpectingTypeAnnotation |
(EvaluatorFlags.ExpectingTypeAnnotation |
EvaluatorFlags.VariableTypeAnnotation |
EvaluatorFlags.AllowForwardReferences |
EvaluatorFlags.NotParsedByInterpreter |

View File

@ -2,6 +2,9 @@
# handle various class definition cases.
from typing import Type
class Foo:
pass
@ -22,3 +25,18 @@ class Bar3(Foo, metaclass=type, metaclass=type):
class Bar4(Foo, other_keyword=2):
pass
class A:
...
class B:
C: Type[A]
app = B()
class D(app.C):
...