Fixed regression that results in the incorrect type evaluation for the value attribute of a StrEnum or IntEnum class. This addresses #7983.

This commit is contained in:
Eric Traut 2024-05-23 09:18:17 -07:00
parent bfc60526a0
commit aed4c75980
2 changed files with 4 additions and 3 deletions

View File

@ -587,9 +587,10 @@ export function getTypeOfEnumMember(
if (memberName === 'value' || memberName === '_value_') {
// Does the class explicitly override this member? Or it it using the
// standard behavior provided by the "Enum" class?
// standard behavior provided by the "Enum" class and other built-in
// subclasses like "StrEnum" and "IntEnum"?
const memberInfo = lookUpClassMember(classType, memberName);
if (memberInfo && isClass(memberInfo.classType) && !ClassType.isBuiltIn(memberInfo.classType, 'Enum')) {
if (memberInfo && isClass(memberInfo.classType) && !ClassType.isBuiltIn(memberInfo.classType)) {
return undefined;
}

View File

@ -217,7 +217,7 @@ reveal_type(te15_A.value, expected_text="str")
reveal_type(te15_A._value_, expected_text="str")
class TestEnum16(Enum):
class TestEnum16(IntEnum):
A = 1
B = 2
C = 3