PyType (@NotNull PyFunction function, @NotNull TypeEvalContext context) { if (isInitMethod(function)) { final PyClass cls = function.getContainingClass(); if (cls != null) { for (PyTypeProvider provider : PyTypeProvider.EP_NAME.getExtensionList()) { final PyType providedClassType = provider.getGenericType(cls, context); if (providedClassType != null) { return providedClassType; } } final PyInstantiableType classType = as(context.getType(cls), PyInstantiableType.class); if (classType != null) { return classType.toInstance(); } } } return context.getReturnType(function); }