LanguageLevel (@NotNull PyElement element) { PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof PyiFile) { PsiElement impl = getOriginalElement(element); if (impl != null) { return LanguageLevel.forElement(impl); } else { // XXX: Relying on the fact .pyi files still have the language level key set by the pusher return PythonLanguageLevelPusher.getLanguageLevelForVirtualFile(element.getProject(), containingFile.getVirtualFile()); } } return LanguageLevel.forElement(element); }