Set<PyClass> (@NotNull PsiElement anchor, @NotNull Set<String> seenAttrs, @NotNull TypeEvalContext context) { final Set<PyClass> candidates = new HashSet<>(); final Map<PyClass, Set<PyClass>> ancestorsCache = Maps.newHashMap(); for (String attribute : seenAttrs) { // Search for some of these attributes like __init__ may produce thousands of candidates in average SDK if (COMMON_OBJECT_ATTRIBUTES.contains(attribute)) { candidates.add(PyBuiltinCache.getInstance(anchor).getClass(PyNames.OBJECT)); } else { final Collection<PyClass> declaringClasses = PyClassAttributesIndex.find(attribute, anchor.getProject()); if (LOG.isDebugEnabled()) { LOG.debug("Classes containing " + attribute + ": " + ContainerUtil.map(declaringClasses, AttributesCompletionProvider::debugClassCoordinates)); } candidates.addAll(declaringClasses); } } final Set<PyClass> suitableClasses = new HashSet<>(); for (PyClass candidate : candidates) { if (PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(candidate.getContainingFile())) { continue; } final Set<String> inherited = getAllInheritedAttributeNames(candidate, context, ancestorsCache); if (LOG.isDebugEnabled()) { LOG.debug("All attributes of " + debugClassCoordinates(candidate) + ": " + inherited); } if (inherited.containsAll(seenAttrs)) { suitableClasses.add(candidate); } } return Collections.unmodifiableSet(suitableClasses); }