mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
PY-79330 Assertion fix
GitOrigin-RevId: 57599c47328eb97136b44e75c4e3341780e6ba50
This commit is contained in:
committed by
intellij-monorepo-bot
parent
129c65214c
commit
613ca4396b
@@ -116,15 +116,17 @@ public final class PyStdlibTypeProvider extends PyTypeProviderBase {
|
||||
PyClassType enumType = as(context.getType(qualifier), PyClassType.class);
|
||||
if (enumType != null) {
|
||||
PyClass enumClass = enumType.getPyClass();
|
||||
PyTargetExpression firstEnumItem = ContainerUtil.getFirstItem(enumClass.getClassAttributes());
|
||||
if (firstEnumItem != null) {
|
||||
EnumAttributeInfo attributeInfo = getEnumAttributeInfo(enumClass, firstEnumItem, context);
|
||||
if (attributeInfo != null) {
|
||||
return Ref.create(attributeInfo.assignedValueType);
|
||||
if (isCustomEnum(enumClass, context)) {
|
||||
PyTargetExpression firstEnumItem = ContainerUtil.getFirstItem(enumClass.getClassAttributes());
|
||||
if (firstEnumItem != null) {
|
||||
EnumAttributeInfo attributeInfo = getEnumAttributeInfo(enumClass, firstEnumItem, context);
|
||||
if (attributeInfo != null) {
|
||||
return Ref.create(attributeInfo.assignedValueType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Ref.create();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return Ref.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4163,6 +4163,19 @@ public class PyTypeTest extends PyTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// PY-79330
|
||||
public void testTypeHintedEnumItemValueAttribute2() {
|
||||
runWithLanguageLevel(
|
||||
LanguageLevel.getLatest(),
|
||||
() -> doTest("() -> Any", // Should be 'Any' PY-71603
|
||||
"""
|
||||
from enum import Enum
|
||||
|
||||
def f(p: Enum):
|
||||
expr = p.value""")
|
||||
);
|
||||
}
|
||||
|
||||
// PY-54503
|
||||
public void testImportedEnumGetItemResultValueAttribute() {
|
||||
myFixture.copyDirectoryToProject(TEST_DIRECTORY + getTestName(false), "");
|
||||
|
||||
Reference in New Issue
Block a user