Optional<Boolean> (@NotNull PyClassType expected, @Nullable PyType actual) { if (ArrayUtil.contains(expected.getName(), PyNames.OBJECT, PyNames.TYPE)) { final PyBuiltinCache builtinCache = PyBuiltinCache.getInstance(expected.getPyClass()); if (expected.equals(builtinCache.getObjectType())) { return Optional.of(true); } if (expected.equals(builtinCache.getTypeType()) && actual instanceof PyInstantiableType && ((PyInstantiableType<?>)actual).isDefinition()) { return Optional.of(true); } } return Optional.empty(); }