mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-80002 Remove excessive version checks in PyResolveUtil.allowForwardReferences
`from __future__ import annotations` is not available in Python < 3.7, and in earlier versions such import itself should be highlighted, and using type parameter lists in Python < 3.12 is already reported. GitOrigin-RevId: 18075131473fb5cee8a47ab259cfdc753889892e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
172d60f843
commit
4e7181a473
@@ -424,15 +424,12 @@ public final class PyResolveUtil {
|
||||
// Forward references are allowed in annotations according to PEP 563
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file instanceof PyFile pyFile) {
|
||||
LanguageLevel languageLevel = pyFile.getLanguageLevel();
|
||||
boolean nonEagerEvaluationEnabled =
|
||||
(languageLevel.isAtLeast(LanguageLevel.PYTHON37) && pyFile.hasImportFromFuture(FutureFeature.ANNOTATIONS))
|
||||
|| languageLevel.isAtLeast(LanguageLevel.PYTHON314);
|
||||
boolean nonEagerEvaluationEnabled = pyFile.hasImportFromFuture(FutureFeature.ANNOTATIONS) ||
|
||||
pyFile.getLanguageLevel().isAtLeast(LanguageLevel.PYTHON314);
|
||||
boolean insideAnnotation = PsiTreeUtil.getParentOfType(element, PyAnnotation.class) != null;
|
||||
if (insideAnnotation && nonEagerEvaluationEnabled) return true;
|
||||
|
||||
boolean isReferenceFromTypeParameterList = languageLevel.isAtLeast(LanguageLevel.PYTHON312) &&
|
||||
PsiTreeUtil.getParentOfType(element, PyTypeParameter.class, true) != null;
|
||||
boolean isReferenceFromTypeParameterList = PsiTreeUtil.getParentOfType(element, PyTypeParameter.class, true) != null;
|
||||
if (isReferenceFromTypeParameterList) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user