0

In Python, blank lines should not contain whitespace. However, if I double return to create a blank line for readability, JupyterLab isn't automatically deleting the whitespace it automatically added in the first place to maintain indentation level. So naturally, my code is full of blank lines that contain whitespace. Yet, I only get the warnings sometimes, e.g. if I re-open a notebook.

Is this a bug(s)? Should the IDE (JupyterLab 3.1.8, via JupyterHub) be removing them automatically? I'd be surprised to learn that intended default behavior results in so many warnings without manual removal. And why am I only seeing the warnings sometimes?

I see from a related question that there may be extensions to remove the whitespace or suppress the warning, but it seems wrong that what I'm experiencing should require IDE modification (or even settings changes, really) to avoid.

enter image description here

Evan
  • 435
  • 3
  • 12
  • This is not a default behaviour of JupyterLab. The warnings are coming from an extension that someone had to install on your JupyterHub (either you or an administrator of your JupyterHub). This extension is called `jupyterlab-lsp` and enables coding assistance such as these warnings as a primary feature; you can however filter which warnings you want to see as explained in https://stackoverflow.com/questions/67669843/jupyterlab-3-0-14-how-to-disable-code-style-highlights-pycodestyle/67671347#67671347 – krassowski Jan 22 '22 at 19:49
  • Also, there is a feature request to automatically remove trailing whitespace (https://github.com/jupyterlab/jupyterlab/issues/3904); we are currently migrating to a newer version of CodeMirror which will enable this in version 4.0+ You are welcome to contribute. Please be considerate, writing *I can't believe I'm expected to remove them all manually* does not sound good when read by an author of a free open-source extension who is trying to help people by enabling them to write better code in a more productive fashion; not my fault that someone installed my extension on your system... – krassowski Jan 22 '22 at 19:54
  • 1
    @krassowski thanks for all the helpful comments! Not complaining, just (correctly, it seems) assuming that this isn't default/intended behavior of such a nice (free!) tool. Reworded. – Evan Jan 22 '22 at 20:06

0 Answers0