Skip to main content

Flake8 based checking for jupyter notebooks

Project description

flake8-nb

PyPi Version Conda Version Supported Python Versions Pre-commit License

Actions Status Documentation Status Testing Coverage Documentation Coverage Dependabot Status

Code quality All Contributors Code style Python: black Binder

flake8 checking for jupyter notebooks. Basically this is a hack on the flake8's Application class, which adds parsing and a cell based formatter for *.ipynb files.

This is NOT A PLUGIN but a stand alone CLI tool/pre-commit hook to be used instead of the flake8 command/hook.

Features

  • flake8 CLI tests for jupyter notebooks
  • Full base functionality of flake8 and its plugins
  • Input cell based error formatting (Execution count/code cell count/total cellcount)
  • Report fine tuning with cell-tags (flake8-noqa-tags see usage)
  • pre-commit hook

Examples

Default reporting

If you had a notebook with name example_notebook.ipynb, where the code cell which was executed as 34th cell (In[34]) had the following code:

bad_formatted_dict = {"missing":"space"}

running flake8_nb would result in the following output.

Execution count

$ flake8_nb example_notebook.ipynb
example_notebook.ipynb#In[34]:1:31: E231 missing whitespace after ':'

Custom reporting

If you prefer the reports to show the cell number rather then the execution count you can use the --notebook-cell-format option, given that the cell is the 5th code cell and 10th total cell (taking raw and markdown cells into account), you will get the following output.

Code cell count

$ flake8_nb --notebook-cell-format '{nb_path}:code_cell#{code_cell_count}' example_notebook.ipynb
example_notebook.ipynb:code_cell#5:1:31: E231 missing whitespace after ':'

Total cell count

$ flake8_nb --notebook-cell-format '{nb_path}:cell#{total_cell_count}' example_notebook.ipynb
example_notebook.ipynb:cell#10:1:31: E231 missing whitespace after ':'

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Sebastian Weigand

💻 🤔 🚧 📆 🚇 ⚠️ 📖

Jt Miclat

🐛

Philipp Eisenhauer

🐛

Shoma Okamoto

⚠️

Marco Gorelli

🔧 📖

Tony Hirst

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_nb-0.3.1.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

flake8_nb-0.3.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file flake8_nb-0.3.1.tar.gz.

File metadata

  • Download URL: flake8_nb-0.3.1.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for flake8_nb-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f7f898c66cd87a879c09db1ca66b924f007efa8fd2c7a291ca73cf7a23309373
MD5 82d7f9e7a90e93e87e802c0ae43f4c92
BLAKE2b-256 96c5c2cd0e518a16538ea57e4ff4fb6cddfdec94ce6e9d6716eb9fcabb0dbaca

See more details on using hashes here.

File details

Details for the file flake8_nb-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: flake8_nb-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for flake8_nb-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 370a73363159fb0378adb27b66cc6c0f8dd51f6ebe1544b6f1196f241963e5a3
MD5 52739a4874cfbc33fce75a88ed7d4c8f
BLAKE2b-256 cf94634c99fc27b0b1a76e70b12d5c0a296c6dbf1b4c4ad504491315644de31d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page