boolean (@NotNull PyQualifiedExpression element) { // Allow forward references in Pyi files if (PyiUtil.isInsideStub(element)) { return true; } // Forward references are allowed in annotations according to PEP 563 PsiFile file = element.getContainingFile(); if (file instanceof PyFile pyFile) { return pyFile.getLanguageLevel().isAtLeast(LanguageLevel.PYTHON37) && pyFile.hasImportFromFuture(FutureFeature.ANNOTATIONS) && PsiTreeUtil.getParentOfType(element, PyAnnotation.class) != null; } return false; }