public static boolean isAbsoluteImportEnabledFor(PsiElement foothold) { if (foothold != null) { PsiFile file = foothold.getContainingFile(); if (file instanceof PyFile) { final PyFile pyFile = (PyFile) file; if (pyFile.getLanguageLevel().isPy3K()) { return true; } return pyFile.hasImportFromFuture(ABSOLUTE_IMPORT); } } // if the relevant import is below the foothold, it is either legal or we've detected the // offending statement already return false; }