{"id":19183919,"url":"https://github.com/mhitza/flake8-jupyter-notebook","last_synced_at":"2025-05-07T23:49:38.332Z","repository":{"id":47177575,"uuid":"263094687","full_name":"mhitza/flake8-jupyter-notebook","owner":"mhitza","description":"GitHub Action that runs flake8 code checks on Python code within Jupyter Notebooks","archived":false,"fork":false,"pushed_at":"2024-06-04T22:07:02.000Z","size":55,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T23:49:28.235Z","etag":null,"topics":["flake8","jupyter-notebook","python-notebook"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mhitza.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-11T16:16:33.000Z","updated_at":"2024-06-04T22:07:05.000Z","dependencies_parsed_at":"2023-01-04T12:29:07.491Z","dependency_job_id":null,"html_url":"https://github.com/mhitza/flake8-jupyter-notebook","commit_stats":{"total_commits":56,"total_committers":2,"mean_commits":28.0,"dds":0.0535714285714286,"last_synced_commit":"fb6e90e0d821c78f8c2b8e14fb78f9bb4af57aef"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhitza%2Fflake8-jupyter-notebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhitza%2Fflake8-jupyter-notebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhitza%2Fflake8-jupyter-notebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhitza%2Fflake8-jupyter-notebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhitza","download_url":"https://codeload.github.com/mhitza/flake8-jupyter-notebook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973626,"owners_count":21834105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flake8","jupyter-notebook","python-notebook"],"created_at":"2024-11-09T11:05:33.131Z","updated_at":"2025-05-07T23:49:38.316Z","avatar_url":"https://github.com/mhitza.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A container and a wrapper script around [flake8][1] to validate python code within Jupyter\nnotebooks. flake8 will pick up configuration files in your project, but [some options are not supported](#flake8-configuration-support) and\nwill cause the action to fail (sometimes silently).\n\n\n## Motivation\n\nAn easy way to automate [flake8][1] code checks over code blocks defined in a\nJupyter notebook.\n\n\n## Example usage\n\n```yaml\njobs:\n  flake8:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v4\n    - uses: mhitza/flake8-jupyter-notebook@v1\n      with:\n        debug: 'false' # set 'true' for additional logging\n        # paths and files to ignore, one regexp rule per line\n        ignore: |\n          tests/\n          test\\.ipynb$\n```\n\n![annotation-screenshot]\n\n\n## Implementation details\n\nThere is an existing project, called [flake8-nb][3] that performs the same task as this\naction. While initial implementation tried to wrapp the annotation script around that\nutility, it was abandoned and instead flake8 was used because:\n\n  1. [flake8-nb][3] did not report absolute line number within the notebook file, instead it\n     reported only relative line numbers within the checked code blocks.\n  2. A notebook might be checked in the repository without the code cells\n     evaluated. In that case [flake8-nb][3] would report on cells without a number,\n     and tracking back from the reported error to absolute line numbers became a more\n     difficult task than wrapping around [flake8][1].\n\nIn order to check the notebook, the [annotate][4] script keeps track of all the various code\nblocks within the notebook, concatenates them into a single source and pipes it into [flake8][1].\n\n\n## Known limitations\n\n**Supports version 4 compatible notebook formats**. It will just silently skip\nover other notebook formats, as it's using *regular expressions based on indentation level* to\nextract source blocks. If you're of aware of any JavaScript JSON parser that keeps track of the\nsource lines parsed I'd be happy to hear about it.\n\n\nDue to implementation details and Jupyter notebook specific idiosyncrasies, some warnings and errors\nreported by [flake8][1] are ignored by default (hardcoded in source code). The following list is not\nnecessarily exhaustive and might change based on testing and issues raised.\n\n - [E302 Expected 2 blank lines][E302] when reported for the first line of a code block.\n - [E305 Expected 2 blank lines after end of function or class][E305], as with E302,\n   when reported for the first line of a code block.\n - [E402 Module level import not at top of file][E402]. In tested notebooks\n   code sections will tend to import modules just before usage.\n - [F821 Undefined name name][F821]. When the undefined name stands for the Jupyter builtin function\n   `display`\n\n\n\n### flake8 configuration support\n\nThe following options which can be defined in a flake8 configuration file are not supported.\n\nAny option that changes the output of flake8: `--quiet`, `--count`, `--format` (only default supported),\n`--show-source`, `--statistics`.\n\nAnything that relies on filename/paths, as code is passed in to flake8 via stdin.\nThus the following options will have no effect: `--exclude`, `--extend-exclude`, `--filename`, `--per-file-ignores`\n\n\n[1]: https://flake8.pycqa.org/en/latest/\n[annotation-screenshot]: https://user-images.githubusercontent.com/273079/82093965-d6585d00-9704-11ea-9159-c8b72a9b89c8.png\n[3]: https://github.com/s-weigand/flake8-nb\n[4]: annotate\n[E302]: https://archive.vn/Bj1tc\n[E305]: https://archive.vn/a3tr2\n[E402]: https://archive.vn/i7NWk\n[F821]: https://archive.ph/Ysz7l\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhitza%2Fflake8-jupyter-notebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhitza%2Fflake8-jupyter-notebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhitza%2Fflake8-jupyter-notebook/lists"}