Package: nbqa
Run ruff, isort, pyupgrade, mypy, pylint, flake8, black, blacken-docs, and more on Jupyter Notebooks✅ handles IPython magics robustly✅ respects your config files✅ preserves "quiet mode" trailing semicolons✅ lints both code and markdown cellsTable of contentsTable of contents🎉 Installation🚀 ExamplesCommand-linePre-commit🥳 Used by💬 Testimonials👥 Contributing🎉 InstallationIn yourvirtual environment, run (note: the$is not part of the command):$python-mpipinstall-UnbqaTo also install all supported linters/formatters:$python-mpipinstall-U"nbqa[toolchain]"🚀 ExamplesCommand-lineReformat your notebooks withblack:$nbqablackmy_notebook.ipynbreformatted my_notebook.ipynbAll done! ✨ 🍰 ✨1 files reformatted.Sort your imports withisort:$nbqaisortmy_notebook.ipynb--float-to-topFixing my_notebook.ipynbUpgrade your syntax withpyupgrade:$nbqapyupgrademy_notebook.ipynb--py37-plusRewriting my_notebook.ipynbFormat your markdown cells withblacken-docs:$nbqablacken-docsmy_notebook.ipynb--nbqa-md--nbqa-diffCell 2--------- my_notebook.ipynb+++ my_notebook.ipynb@@ -1,2 +1 @@-First level heading-===+# First level headingTo apply these changes, remove the `--nbqa-diff` flagFormat.mdfiles saved viaJupytext(requiresjupytextto be installed):$nbqablackmy_notebook.mdreformatted my_notebook.mdAll done! ✨ 🍰 ✨1 files reformatted.Seecommand-line examplesfor examples involvingdoctest,flake8,mypy,pylint,autopep8,pydocstyle,yapf, andruff.Pre-commitHere's an example of how to set up some pre-commit hooks: put this in your.pre-commit-config.yamlfile (seeusage as pre-commit hook)-repo:https://github.com/nbQA-dev/nbQArev:1.7.1hooks:-id:nbqa-blackadditional_dependencies:[jupytext]# optional, only if you're using Jupytext-id:nbqa-pyupgradeargs:["--py37-plus"]-id:nbqa-isortargs:["--float-to-top"]If you need to select specific versions of these linters/formatters,
add them toadditional_dependencies.🥳 Used byClick here for (non-exhaustive) list of reposhttps://github.com/ComPWA/ampformhttps://github.com/ComPWA/tensorwaveshttps://github.com/DataS-DHSC/os-maps-examplehttps://github.com/Eazhi/World-Happiness-Analysishttps://github.com/GoogleCloudPlatform/ai-platform-sampleshttps://github.com/MRCIEU/epigraphdbhttps://github.com/OpenMined/PyDPhttps://github.com/PlasmaPy/PlasmaPyhttps://github.com/ProjectPythia/pythia-foundationshttps://github.com/SeldonIO/alibihttps://github.com/TeoZosa/deep-learning-v2-pytorchhttps://github.com/WM-SEMERU/mlproj_templatehttps://github.com/alan-turing-institute/sktimehttps://github.com/amor71/LiuAlgoTraderhttps://github.com/bbernst/base_envshttps://github.com/cheginit/HyRiver-exampleshttps://github.com/cheginit/pygeohydrohttps://github.com/cheginit/pynhdhttps://github.com/covid-19-impact-lab/sid-germanyhttps://github.com/covid-19-impact-lab/sidhttps://github.com/dapperfu/Python-Simulinkhttps://github.com/deepcharles/ruptureshttps://github.com/dhassault/cyclegan_pytorchhttps://github.com/gboeing/osmnxhttps://github.com/glotzerlab/freud-exampleshttps://github.com/glotzerlab/hoomd-exampleshttps://github.com/glotzerlab/signac-docshttps://github.com/glotzerlab/signac-exampleshttps://github.com/grapl-security/graplhttps://github.com/hainegroup/oceanspyhttps://github.com/henryiii/python-compiled-minicoursehttps://github.com/intake/intake-esmhttps://github.com/jameslamb/lightgbm-dask-testinghttps://github.com/jdb78/pytorch-forecastinghttps://github.com/jhrcook/advent-of-code_2020https://github.com/julian-west/asset_price_correlationshttps://github.com/kratsg/drstoragehttps://github.com/madebr/pyOpthttps://github.com/matthewfeickert/heputilshttps://github.com/matyama/deep-rl-hands-onhttps://github.com/mayou36/raredecayhttps://github.com/neomatrix369/nlp_profilerhttps://github.com/openforcefield/openff-systemhttps://github.com/pandas-profiling/pandas-profilinghttps://github.com/paw-lu/dotfileshttps://github.com/pawamoy/wps-lighthttps://github.com/phinate/clarinethttps://github.com/pik-primap/climate_categorieshttps://github.com/pik-primap/primap2https://github.com/pik-primap/unfccc_di_apihttps://github.com/pymc-devs/pymc-exampleshttps://github.com/pymc-devs/resourceshttps://github.com/saturncloud/exampleshttps://github.com/scikit-hep/boost-histogramhttps://github.com/scikit-hep/iminuithttps://github.com/scikit-hep/mplhephttps://github.com/scikit-hep/pyhfhttps://github.com/scikit-hep/pylhehttps://github.com/v-goncharenko/data-science-templatehttps://github.com/wemake-services/wemake-python-styleguidehttps://github.com/zfit/phasespacehttps://github.com/zfit/zfithttps://github.com/zfit/zfit-physicshttps://github.com/zfit/zfit-tutorialsIs your project missing? Let us know, or open a pull request!💬 TestimonialsMichael 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 lackingNikita Sobolev,CTO at wemake.services:It is amazing!Alex Andorra,Data Scientist, ArviZ & PyMC Dev, Host of 'Learning Bayesian Statistics' Podcast:well done onnbqa@MarcoGorelli ! Will be super useful in CIMatthew 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 toolSimon 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 maintainertoday I learned aboutnbqa, a command-line tool to run linters likeflake8over #Python code in @ProjectJupyter notebooks. Thanks to @jayyqi for pointing me to it. So far, I really really like it.Lars Yencken,Tech Lead @ Our World In DataSuper useful! I only wish it was built-in to Jupyterlab.Vincent D. Warmerdam,maintainer @ calmcode.ioNice. nbQA looks like a great way to prevent the Untitled12.ipynb-phenomenon. I like!Mani Sarkar,Kaggle 3x expert, contributornbQA is an inspiring project, and the team behind it are very knowledgeable and think of things outside the box with ideas and solutions👥 ContributingI will give write-access to anyone who makes a useful pull request - see thecontributing guidefor 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🐛Rafal Wojdyla🐛Bradley Dice🤔💻Ivan Cheung🐛Tony Hirst🐛Taneli Hukkinen🚧Tom Begley🤔💻📖Steven DeMartini📖vincent d warmerdam✅Daniel Sparing🐛asdfCYBER📖Chris Knight🐛Laura Richter🤔Francesco Ballarin🐛Janosh Riebesell🐛📖Nicolas Oliver🐛Bas Nijholt🤔Ralf Gommers🤔Toon Verstraelen📖Trinh Quoc Anh🐛Martin K. Scherer💻Felix Williams🐛🚇Florian Bär📖Michael Kennedy🔊Brian Okken🔊This project follows theall-contributorsspecification.
Contributions of any kind welcome!