boolean (@NotNull PyReferenceExpression location, @NotNull TypeEvalContext context) { final PyFunction function = as(getCallable(), PyFunction.class); final boolean isNonStaticMethod = function != null && function.getContainingClass() != null && function.getModifier() != STATICMETHOD; if (isNonStaticMethod) { // In Python 2 unbound methods have __method fake type if (LanguageLevel.forElement(location).isPython2()) { return true; } final PyExpression qualifier; if (location.isQualified()) { qualifier = location.getQualifier(); } else { final PyResolveContext resolveContext = PyResolveContext.defaultContext(context); qualifier = ContainerUtil.getLastItem(location.followAssignmentsChain(resolveContext).getQualifiers()); } if (qualifier != null) { final PyType qualifierType = context.getType(qualifier); if (PyTypeUtil.toStream(qualifierType).select(PyClassType.class).anyMatch(it -> !it.isDefinition())) { return true; } } } return false; }