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.
Type Name Latest commit message Commit time
Failed to load latest commit information.
img Delete test.t Dec 14, 2018
tests Rename Flake8 test class Jan 4, 2019
.gitignore Ignore ipynb checkpoints Jan 4, 2019
LICENSE Add files via upload Nov 9, 2017 Update README with configuration subsection Jan 4, 2019 bump to v0.2.5 Jan 8, 2019
pyproject.toml Add files via upload Nov 9, 2017


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


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

pip install flake8 pycodestyle pycodestyle_magic


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


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:


or for 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

You can’t perform that action at this time.