Repolode
nbQA-dev

nbQA-dev/nbQA

A CLI tool that runs Python linters and formatters such as ruff, isort, black, mypy and flake8 directly on Jupyter Notebooks.

Stars
1,208
Forks
52
Open issues
24
Last commit
7 hours ago

What is it?

nbQA lets you run standard Python code quality tools on Jupyter Notebooks without converting them to scripts first. Notebook code cells are checked as Python, and markdown cells can be processed by tools such as blacken-docs. It works with a wide range of tools, including black, isort, pyupgrade, ruff, flake8, mypy, pylint, yapf, autopep8, pydocstyle and doctest.

The tool handles IPython magics, respects existing configuration files, and preserves trailing semicolons used to suppress notebook output. It also accepts Jupytext-paired .md notebooks. It can be run from the command line or wired into pre-commit hooks, so notebooks get the same checks as the rest of a codebase.

Key features

  • 01Runs black, isort, ruff, flake8, mypy, pylint and other tools on notebook code cells
  • 02Processes markdown cells with tools such as blacken-docs
  • 03Handles IPython magics without breaking notebook code
  • 04Respects existing tool configuration files
  • 05Works with Jupytext-formatted .md notebooks
  • 06Provides pre-commit hook integration

Use cases

  • Enforcing lint and formatting standards across data science notebooks in a repository
  • Running type checks with mypy on notebooks in CI pipelines
  • Auto-formatting notebook code and markdown documentation before committing
  • Upgrading Python syntax across a collection of older notebooks

Quick start

  1. 1

    Install nbQA with pip in your virtual environment

    python -m pip install -U nbqa
  2. 2

    Optionally install all supported linters and formatters

    python -m pip install -U "nbqa[toolchain]"
  3. 3

    Run a formatter on a notebook, for example black

    nbqa black my_notebook.ipynb

Things to know

  • Each linter or formatter must be installed separately unless you use the toolchain extra.

Topics

FAQ

What is nbQA?
A CLI tool that runs Python linters and formatters such as ruff, isort, black, mypy and flake8 directly on Jupyter Notebooks. nbQA lets you run standard Python code quality tools on Jupyter Notebooks without converting them to scripts first. Notebook code cells are checked as Python, and markdown cells can be processed by tools such as blacken-docs. It works with a wide range of tools, including black, isort, pyupgrade, ruff, flake8, mypy, pylint, yapf, autopep8, pydocstyle and doctest.
Is nbQA free to use? What license does it have?
nbQA is open source under the MIT license. Check the license terms before using it in commercial products.
Is nbQA still maintained?
Actively maintained. The last commit to nbQA was on Nov 6, 2026.
What can I use nbQA for?
Enforcing lint and formatting standards across data science notebooks in a repository Running type checks with mypy on notebooks in CI pipelines Auto-formatting notebook code and markdown documentation before committing Upgrading Python syntax across a collection of older notebooks
How do I install nbQA?
Install nbQA with pip in your virtual environment: python -m pip install -U nbqa Optionally install all supported linters and formatters: python -m pip install -U "nbqa[toolchain]" Run a formatter on a notebook, for example black: nbqa black my_notebook.ipynb
Where can I get nbQA?
The source code and installation instructions are on GitHub: https://github.com/nbQA-dev/nbQA

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects