jupyterlab-lsp icon indicating copy to clipboard operation
jupyterlab-lsp copied to clipboard

pycodestyle false positive

Open djangoliv opened this issue 1 year ago • 3 comments
trafficstars

Description

When a code cell is after a markdown cell, pycodestyle warns an error E303 (too many blank lines 3).

image

Reproduce

  • install jupyterlab, jupyterlab-lsp and 'python-lsp-server[all]'
  • open jupyterlab
  • open a new notebook
  • create a simple markdown cell
  • create a simple code cell with a function (or anything)

Expected behavior

No warnings

Context

jupyterlab 4.1.0 jupyterlab-lsp 5.0.3 pycodestyle 2.11.1

Regards

djangoliv avatar Feb 09 '24 14:02 djangoliv

Thanks! This is a bug in JupyterLab itself - when the code of jupyterlab-lsp was moved to JupyterLab (in 4.0 release) the contributor who did that also added support for Markdown documents by using extractors mechanisms; it seems that markdown cells are erroneously included as empty cells in the resulting Python document.

It seems that the logic in TextForeignCodeExtractor and in the extractForeignCode() or appendCodeBlock need to be modified so that when an entire cell gets extracted, rather than adding an empty code cell equivalent (padded by two empty lines on each side) no cell would be added instead.

krassowski avatar Feb 25 '24 15:02 krassowski

I opened an issue in JupyterLab to track this: https://github.com/jupyterlab/jupyterlab/issues/15870

krassowski avatar Feb 25 '24 16:02 krassowski

Workaround

  1. Go to Settings > Settings Editor > Code Diagnostics
  2. Under Diagnostic codes to ignore, add E303

Screenshot 2024-08-05 at 21 47 20

drichardson avatar Aug 06 '24 04:08 drichardson