void (@NotNull PyBinaryExpression node) { if (node.getOperator() != PyTokenTypes.OR) return; final PsiFile file = node.getContainingFile(); final boolean isInAnnotation = PsiTreeUtil.getParentOfType(node, PyAnnotation.class, false, PyStatement.class) != null; if (file == null || file instanceof PyFile && ((PyFile)file).hasImportFromFuture(FutureFeature.ANNOTATIONS) && isInAnnotation) { return; } final TypeEvalContext context = TypeEvalContext.codeAnalysis(node.getProject(), node.getContainingFile()); // Consider only full expression not parts to have only one registered problem if (PsiTreeUtil.getParentOfType(node, PyBinaryExpression.class, true, PyStatement.class) != null) return; final Ref<PyType> refType = PyTypingTypeProvider.getType(node, context); if (refType != null && refType.get() instanceof PyUnionType) { if (isInAnnotation) { registerForAllMatchingVersions(level -> level.isOlderThan(LanguageLevel.PYTHON310), PyPsiBundle.message("INSP.compatibility.new.union.syntax.not.available.in.earlier.version"), node, new ReplaceWithOldStyleUnionQuickFix(), new AddFromFutureImportAnnotationsQuickFix()); } else { registerForAllMatchingVersions(level -> level.isOlderThan(LanguageLevel.PYTHON310), PyPsiBundle.message("INSP.compatibility.new.union.syntax.not.available.in.earlier.version"), node, new ReplaceWithOldStyleUnionQuickFix()); } } }