Skip to content
magic function for pycodestyle module in Jupyter Lab and Notebook
Jupyter Notebook Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
img Delete test.t Dec 14, 2018
notebook
tests Rename Flake8 test class Jan 4, 2019
.gitignore Ignore ipynb checkpoints Jan 4, 2019
LICENSE Add files via upload Nov 9, 2017
README.md Update README with configuration subsection Jan 4, 2019
pycodestyle_magic.py bump to v0.2.5 Jan 8, 2019
pyproject.toml Add files via upload Nov 9, 2017

README.md

pycodestyle_magic

Magic function for pycodestyle and flake8 module in Jupyter-Lab or Notebook

installation

Make sure you've the Python package pycodestyle, flake8 and this pycodestyle_magic.

pip install flake8 pycodestyle pycodestyle_magic

configuration

Flake8 and pycodestyle will discover and manage user configuration files (stored in a user's home directory or in the XDG directory inside their home directory) or project configuration files (stored in the current directory). See their respective docs for specific details on configuration file naming, syntax, and location.

Additionally, Flake8 cell magic ignores four codes by default:

  • W292 - no newline at end of file; not relevant in an iPython cell
  • W391 - blank line at end of file; not relevant in an iPython cell
  • F401 - module imported but unused; a module may be imported in one cell and used in another
  • F821 - undefined name name; a variable may be defined in one cell and used in another

usage

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

See notebooks in notebook directory for example use cases, as such:

Pycodestyle (notebook)

alt text

Flake8 (notebook)

alt text

Examples notebooks were slightly adapted from https://github.com/SiggyF/notebooks/blob/master/styleguide.ipynb

You can’t perform that action at this time.