Need help with nbQA?
Click the β€œchat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

nbQA-dev
183 Stars 11 Forks MIT License 445 Commits 20 Opened issues

Description

Run any standard Python code quality tool on a Jupyter Notebook

Services available

!
?

Need anything else?

Contributors list

nbQA

Run any standard Python code quality tool on a Jupyter Notebook

tox codecov pre-commit

versions chat docs

demo

Table of contents

πŸŽ‰ Installation

In your virtual environment, run one of the following:

  • python -m pip install -U nbqa
    (minimal installation)
  • python -m pip install -U nbqa[toolchain]
    (install supported code quality tools as well)
  • conda install -c conda-forge nbqa
    (if you use conda)

πŸš€ 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: https://github.com/nbQA-dev/nbQA
  rev: 0.5.7
  hooks:
    - id: nbqa-black
      additional_dependencies: [black==20.8b1]
      args: [--nbqa-mutate]
    - id: nbqa-pyupgrade
      additional_dependencies: [pyupgrade==2.10.0]
      args: [--nbqa-mutate, --py36-plus]
    - id: nbqa-isort
      additional_dependencies: [isort==5.7.0]
      args: [--nbqa-mutate]

Command-line

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, and pylint.

πŸ₯³ Used by

Take some inspiration from their config files πŸ˜‰

πŸ’¬ 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 wemake.services:

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!

πŸ‘₯ 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

πŸ’» πŸš‡ πŸ› πŸ‘€ πŸ€”

fcatus

πŸš‡

HD23me

πŸ›

mani

πŸ€” πŸš‡

Daniel Mietchen

πŸ€”

MichaΕ‚ Gacka

πŸ›

Happy

πŸ“–

Nat Taylor

πŸ€” πŸ’» πŸ”§ πŸ›

Caio Ariede

πŸ“–

Nikita Sobolev

πŸ€” πŸ› πŸ“–

Amichay Oren

πŸ€”

pylang

πŸ€”

Henry Schreiner

πŸ›

Kaiqi Dong

πŸ“–

Simon Brugman

πŸ›

John Sandall

πŸ›

Nathan Cooper

πŸ›

agruenberger

πŸ›

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.