public boolean isProblemSuppressed()

in src/org/jetbrains/plugins/ipnb/IpnbPep8ProblemSuppressor.java [21:50]


  public boolean isProblemSuppressed(@NotNull Pep8ExternalAnnotator.Problem problem,
                                     @NotNull PsiFile file,
                                     @Nullable PsiElement targetElement) {
    if (file instanceof IpnbPyFragment) {
      // Ignore warnings about missing new line at the end of file
      if (problem.getCode().equals("W292")) {
        return true;
      }

      // Ignore warnings about imports not at the top of file if there are magic commands before
      if (problem.getCode().equals("E402") && targetElement != null) {
        final PyImportStatementBase importStatement = PsiTreeUtil.getParentOfType(targetElement, PyImportStatementBase.class);
        if (importStatement != null && importStatement.getParent() == file) {
          boolean containsMagicCommandsBefore = false;
          PsiElement prev = PyPsiUtils.getPrevNonCommentSibling(importStatement, true);
          while (prev != null) {
            if (prev instanceof PyEmptyExpression && prev.getText().startsWith("%")) {
              containsMagicCommandsBefore = true;
            }
            else if (!(isModuleLevelDocstring(prev, (PyFile)file) || prev instanceof PyImportStatementBase)) {
              return false;
            }
            prev = PyPsiUtils.getPrevNonCommentSibling(prev, true);
          }
          return containsMagicCommandsBefore;
        }
      }
    }
    return false;
  }