boolean (@NotNull PyWithAncestors descendant, @NotNull TypeEvalContext context) { if (descendant instanceof PyClass pyClass && pyClass.getTypeParameterList() != null || descendant instanceof PyClassType pyClassType && pyClassType.getPyClass().getTypeParameterList() != null) { return true; } for (PyClassLikeType ancestor : descendant.getAncestorTypes(context)) { if (ancestor != null) { if (GENERIC_CLASSES.contains(ancestor.getClassQName())) { return true; } else if (ancestor instanceof PyClassType classType && classType.getPyClass().getTypeParameterList() != null) { return true; } } } return false; }