mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-19 04:07:36 +03:00
Fixed a false positive error arising from the use of a binary expression for a base class in a class declaration statement. This addresses https://github.com/microsoft/pyright/pull/5326. (#5331)
Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
parent
2de35e3684
commit
02b7769198
@ -999,7 +999,15 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
}
|
||||
|
||||
case ParseNodeType.BinaryOperation: {
|
||||
typeResult = getTypeOfBinaryOperation(evaluatorInterface, node, flags, inferenceContext);
|
||||
let effectiveFlags = flags;
|
||||
|
||||
// If we're expecting an instantiable type and this isn't a union operator,
|
||||
// don't require that the two operands are also instantiable types.
|
||||
if (expectingInstantiable && node.operator !== OperatorType.BitwiseOr) {
|
||||
effectiveFlags &= ~EvaluatorFlags.ExpectingInstantiableType;
|
||||
}
|
||||
|
||||
typeResult = getTypeOfBinaryOperation(evaluatorInterface, node, effectiveFlags, inferenceContext);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,16 @@ class A:
|
||||
pass
|
||||
|
||||
|
||||
def dynamic_subclass(cls: type[T_A]):
|
||||
def dynamic_subclass1(cls: type[T_A]):
|
||||
class SubClass(cls):
|
||||
class SubInnerClass(cls.InnerA):
|
||||
pass
|
||||
|
||||
return SubClass
|
||||
|
||||
|
||||
def dynamic_subclass2(base: type[A] | None):
|
||||
class SubClass(base or A):
|
||||
...
|
||||
|
||||
return SubClass
|
||||
|
Loading…
Reference in New Issue
Block a user