boolean (Editor editor) { if (editor == null) { return false; } Project project = editor.getProject(); if (project == null) { return false; } PsiFile psi = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); return psi instanceof PyFile; }