Open konstantint opened 6 years ago
The right place would be in a notebook extension and not part of Jupyter itself. Like this one for style checks
Can't seem to find a notebook extension for linting though..maybe the core team can point you to something.
I guess a good place to start would be this: https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/code_prettify
Another similar thing, this one invokes mypy on a cell: https://gist.github.com/knowsuchagency/f7b2203dd613756a45f816d6809f01a6
The IHaskell kernel has built-in support for calling hlint
(the Haskell equivalent of pylint). It does not even require cell magics. You can simply turn hlint
checking on and off globally (default is on); see the IHaksell Wiki. It is annoying if you have to add a cell magic to every cell you want to have checked (especially in an educational setting).
Something like that for Python would be wonderful (especially if it would also check type hints).
The https://github.com/mattijn/pycodestyle_magic magic allows you run Flake8
and pycodestyle
checks over code within a particular cell.
From the docs:
Enable the magic function by using the pycodestyle_magic module in a cell
%load_ext pycodestyle_magic
and then use the function in your cell to check compliance with pycodestyle or flake8 as such:
%%pycodestyle
or for flake8
%%flake8
With nbqa its possible to run pylint against Jupyter notebooks from the console, e.g.
nbqa pylint .
https://pypi.org/project/nbqa/
I am still looking for a JupyterLab extension that auto-checks all notebooks and does not need a cell magic etc.
pycodestyle_magic has an option %pycodestyle_on
that enables checks for all cells in a notebook. I would
prefer a plugin with a checkbox "pylint enabled" in its JupyterLab settings.
... and what would be a reasonable approach for implementing it (e.g. what is the most relevant place for plugging in this logic)?