Issue
I want to run Pylint or any equivalent while using Jupyter-Notebook. Is there a way to install and run Pylint this way?
Solution
To answer the question more specifically in regards to pylint
. One relatively simple way to achieve that in a development / ci environment (i.e. command line) is to convert the notebook to Python and then run the linting.
Let's assume you have notebooks in the ./notebooks
folder and you have the jupyter
and pylint
command in the path, you could run the following:
jupyter nbconvert \
--to=script \
--output-dir=/tmp/converted-notebooks/ \
./notebooks/*.ipynb
pylint /tmp/converted-notebooks/*.py
You might want to configure pylint, as the notebook style is slightly different to a general Python module.
Some rules that you might want to disable:
- pointless-statement
- expression-not-assigned
- trailing-newlines
- wrong-import-position
- redefined-outer-name
- invalid-name
It also appears that the maximum number of characters in a cell (before horizontal scrolling) is 116
but that might depend on other factors.
(These options can for example be configured using the --max-line-length
and --disable
pylint arguments, or via the .pylintrc
file)
Answered By - de1
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.