PY-20033 New EP that allows to suppress individual PEP 8 errors in files
[idea/community.git] / python / ipnb / src / org / jetbrains / plugins / ipnb / IpnbPep8ProblemSuppressor.java
1 package org.jetbrains.plugins.ipnb;
2
3 import com.intellij.psi.PsiElement;
4 import com.intellij.psi.PsiFile;
5 import com.jetbrains.python.validation.Pep8ExternalAnnotator;
6 import com.jetbrains.python.validation.Pep8ProblemSuppressor;
7 import org.jetbrains.annotations.NotNull;
8 import org.jetbrains.annotations.Nullable;
9 import org.jetbrains.plugins.ipnb.psi.IpnbPyFragment;
10
11 /**
12  * @author Mikhail Golubev
13  */
14 public class IpnbPep8ProblemSuppressor implements Pep8ProblemSuppressor {
15   @Override
16   public boolean isProblemSuppressed(@NotNull Pep8ExternalAnnotator.Problem problem,
17                                      @NotNull PsiFile file,
18                                      @Nullable PsiElement targetElement) {
19     // Ignore warnings about missing new line at the end of file inside IPython notebook cells
20     return file instanceof IpnbPyFragment && problem.getCode().equals("W292");
21   }
22 }