A GitHub Action to run flake8 checks on the code blocks in Jupyter Notebooks
785
A container and a wrapper script around flake8 to validate python code within Jupyter notebooks.
An easy way to automate the flake8 code checks over the code blocks defined in a Jupyter notebook.
jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: mhitza/flake8-jupyter-notebook@v1

There is an existing project, called flake8-nb that performs the same task as this action. While initial implementation tried to wrapped the annotation script around that utility, it was abandoned and instead flake8 was used instead because:
In order to check the notebook, the annotate script keeps track of all the various code blocks within the notebook, concatenates them into a single file and then pipes it as input to flake8.
First of it only supports version format 4 for notebooks. It will just silently skip over other notebook formats, as it's using regular expressions around indentation level to extract source blocks. If you're of any JavaScript JSON parser that keeps track of the source line parsed I'd be happy to hear about it.
Because of implementation details and Jupyter notebook specifics, some warnings and errors reported by flake8 are ignored. The following list is not necessarily exhaustive and prone to be updated based on more testing.
Content type
Image
Digest
sha256:3e1227d4a…
Size
105.9 MB
Last updated
about 4 years ago
docker pull mhitza/flake8-jupyter-notebook-github-action:v1