Skip to content

magic function for pycodestyle module in Jupyter Lab and Notebook

License

Notifications You must be signed in to change notification settings

bsmoliak/pycodestyle_magic

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

magic function for pycodestyle module in Jupyter Lab and Notebook

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 65.8%
  • Python 34.2%