Skip to content
Switch branches/tags

Latest commit

- [ 21.4b0 → 21.4b2](psf/black@21.4b0...21.4b2)
- [ v2.13.0 → v2.14.0](asottile/pyupgrade@v2.13.0...v2.14.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]>

Git stats


Failed to load latest commit information.


Run any standard Python code quality tool on a Jupyter Notebook

tox codecov pre-commit

versions chat docs


Table of contents

🎉 Installation

In your virtual environment, run one of the following:

  • python -m pip install -U nbqa
  • conda install -c conda-forge nbqa

🚀 Examples

Pre-commit (recommended)

Here's an example of how to set up some pre-commit hooks: put this in your .pre-commit-config.yaml file (see usage as pre-commit hook)

- repo:
  rev: 0.8.0
    - id: nbqa-black
      args: [--nbqa-mutate]
    - id: nbqa-pyupgrade
      args: [--nbqa-mutate, --py36-plus]
    - id: nbqa-isort
      args: [--nbqa-mutate]

If you need to select specific versions of any of these linters/formatters, add them to additional_dependencies.


Reformat your notebooks with black:

$ nbqa black my_notebook.ipynb --nbqa-mutate
reformatted my_notebook.ipynb
All done! ✨ 🍰 ✨
1 files reformatted.

Sort your imports with isort:

$ nbqa isort my_notebook.ipynb --nbqa-mutate
Fixing my_notebook.ipynb

Upgrade your syntax with pyupgrade:

$ nbqa pyupgrade my_notebook.ipynb --py36-plus --nbqa-mutate
Rewriting my_notebook.ipynb

See command-line examples for examples involving autoflake, check-ast, doctest, flake8, mypy, pylint, and yapf.

🥳 Used by

Take some inspiration from their config files 😉

Is your project missing? Let us know, or open a pull request!

💬 Testimonials

Michael Kennedy & Brian Okken, hosts of the Python Bytes podcast:

This is really cool. I think it brings so much of the code formatting and code analysis, clean up to notebooks, which I think had been really lacking

Nikita Sobolev, CTO at

It is amazing!

Alex Andorra, Data Scientist, ArviZ & PyMC Dev, Host of 'Learning Bayesian Statistics' Podcast:

well done on nbqa @MarcoGorelli ! Will be super useful in CI

Matthew Feickert, Postdoc at University of Illinois working on LHC physics:

nbqa in your pre-commit hooks along with @codewithanthony 's pre-commit CI service is amazing! Everyone using Jupyter notebooks should be doing this.

Girish Pasupathy, Software engineer and now core-contributor:

thanks a lot for your effort to create such a useful tool

Simon Brugman, Data scientist & pandas-profiling dev:

nbQA helps us to keep notebooks to the same standards as the rest of the code. If you're serious about your code standards, you should keep them consistent across both notebooks and python scripts. Great addition to the ecosystem, thanks!

Bradley Dice, PhD Candidate in Physics & Scientific Computing:

nbqa is a clean, easy to use, and effective tool for notebook code style. Formatting and readability makes a huge difference when rendering notebooks in a project's documentation!

James Lamb, engineer @saturn_cloud, LightGBM maintainer

today I learned about nbqa, a command-line tool to run linters like flake8 over #Python code in @ProjectJupyter notebooks. Thanks to @jayyqi for pointing me to it. So far, I really really like it.

👥 Contributing

I will give write-access to anyone who makes a useful pull request - see the contributing guide for details on how to do so.

Thanks goes to these wonderful people (emoji key):

Marco Gorelli

💻 🚧 👀 ⚠️ 🤔

Sebastian Weigand

🔧 👀 📖 🤔

Girish Pasupathy

💻 🚇 🐛 👀 🤔






🤔 🚇

Daniel Mietchen


Michał Gacka




Nat Taylor

🤔 💻 🔧 🐛

Caio Ariede


Nikita Sobolev

🤔 🐛 📖

Amichay Oren




Henry Schreiner


Kaiqi Dong


Simon Brugman


John Sandall


Nathan Cooper




Rafal Wojdyla


Bradley Dice

🤔 💻

Ivan Cheung


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