nbQA-dev / nbQA

Run ruff, isort, pyupgrade, mypy, pylint, flake8, and more on Jupyter Notebooks
https://nbqa.readthedocs.io/en/latest/index.html
MIT License
1.01k stars 39 forks source link

Support for ruff format #833

Closed jpmckinney closed 10 months ago

jpmckinney commented 10 months ago

As a fast, equivalent alternative to black: https://astral.sh/blog/the-ruff-formatter

As far as I can tell, I cann't use nbqa to run both the ruff linter ($ ruff) and the ruff formatter ($ ruff format) (I can maybe use addopts to run the formatter instead of the linter – but, in any case, I can't get both to run).

MarcoGorelli commented 10 months ago

hey - doesn't ruff support notebooks now?

jpmckinney commented 10 months ago

Ah, yes, looks like it: https://docs.astral.sh/ruff/faq/#does-ruff-support-jupyter-notebooks

MarcoGorelli commented 10 months ago

cool - closing then, might archive this project then, was fun whilst it lasted 😄

jpmckinney commented 10 months ago

FWIW, ruff format makes other changes to the ipynb file (changing indentation, reordering JSON members, etc.). It doesn't just format the Python code (I would prefer if it could be made to only change Python code, because Google Colab also reformats the ipynb file, and my users often edit notebooks in Colab). I'm sticking with nbqa-black.

I also extend nbqa with custom hooks.

So, nbqa remains independently useful!