diff --git a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java index 61d6c5e13a9f..25437ef8fe99 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java +++ b/python/python-psi-impl/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibTypeProvider.java @@ -16,6 +16,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -124,6 +125,23 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase { return PyTypeParser.getTypeByName(referenceTarget, "dict[str, unknown]", context); } } + @Nullable PyType enumAutoType = getEnumAutoConstructorType(referenceTarget, context, anchor); + if (enumAutoType != null) { + return enumAutoType; + } + return null; + } + + @Nullable + private static PyType getEnumAutoConstructorType(@NotNull PsiElement target, + @NotNull TypeEvalContext context, + @Nullable PsiElement anchor) { + if (target instanceof PyClass && "enum.auto".equals(((PyClass)target).getQualifiedName()) && anchor instanceof PyCallExpression) { + PyClassLikeType classType = as(context.getType((PyTypedElement)target), PyClassLikeType.class); + if (classType != null) { + return new PyCallableTypeImpl(Collections.emptyList(), classType.toInstance()); + } + } return null; } diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java index 68be755d346d..370f7a4ba4de 100644 --- a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java @@ -74,4 +74,14 @@ public class Py3ArgumentListInspectionTest extends PyInspectionTestCase { "\n" + "random.randint(1, 2)"); } + + // PY-53388 + public void testEnumAuto() { + doTestByText("import enum\n" + + "\n" + + "class MyEnum(enum.Enum):\n" + + " FOO = enum.auto()\n" + + " BAR = enum.auto()\n" + + ""); + } }