LanguageLevel (@NotNull PsiElement element) { if (element instanceof PsiDirectory directory) { return PythonLanguageLevelPusher.getLanguageLevelForVirtualFile(directory.getProject(), directory.getVirtualFile()); } final PsiFile containingFile = element.getContainingFile(); if (containingFile instanceof PyFile) { return ((PyFile)containingFile).getLanguageLevel(); } return getDefault(); }