Command-line examples


Cell numbers in the output refer to code cells, enumerated starting from 1.

Reformat your notebooks with black:

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

Run your docstring tests with doctest:

$ nbqa doctest my_notebook.ipynb
File "my_notebook.ipynb", cell_2:11, in my_notebook.add
Failed example:
    add(2, 2)
1 items had failures:
1 of   2 in my_notebook.hello
***Test Failed*** 1 failures.

Check for style guide enforcement with flake8:

$ nbqa flake8 my_notebook.ipynb --extend-ignore=E203,E302,E305,E703
my_notebook.ipynb:cell_3:1:1: F401 'import pandas as pd' imported but unused

Sort your imports with isort:

$ nbqa isort my_notebook.ipynb
Fixing my_notebook.ipynb

Check your type annotations with mypy:

$ nbqa mypy my_notebook.ipynb --ignore-missing-imports
my_notebook.ipynb:cell_10:5: error: Argument "num1" to "add" has incompatible type "str"; expected "int"

Perform static code analysis with pylint:

$ nbqa pylint my_notebook.ipynb --disable=C0114
my_notebook.ipynb:cell_1:5:0: W0611: Unused import datetime (unused-import)

Upgrade your syntax with pyupgrade:

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

Format code with yapf:

$ nbqa yapf --in-place my_notebook.ipynb

Format code with autopep8:

$ nbqa autopep8 -i my_notebook.ipynb

Check docstring style with pydocstyle:

$ nbqa pydocstyle my_notebook.ipynb

Format markdown cells with mdformat:

$ nbqa mdformat my_notebook.ipynb --nbqa-md