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.04k stars 41 forks source link

pre-commit args need to be concatenated #721

Closed amadeuspzs closed 2 years ago

amadeuspzs commented 2 years ago

The pre-commit example is:

  rev: 1.3.1
  hooks:
    - id: nbqa-black
    - id: nbqa-pyupgrade
      args: [--py36-plus]
    - id: nbqa-isort

However, black and isort sometimes fight over module import orders. This is resolved by passing args: ["--profile", "black"] into the precommit config, but for some reason, for the nbqa-isort module only, this needs to be args: ["--profile=black"]

I haven't seen this flagged anywhere so might be specific to my setup.

Is this an issue with pre-commit?

MarcoGorelli commented 2 years ago

Hi @amadeuspzs - you can put profile=black in your configuration file (e.g. pyproject.toml - see https://pycqa.github.io/isort/docs/configuration/config_files.html)

but for some reason, for the nbqa-isort module only, this needs to be args: ["--profile=black"]

yeah unfortunately pre-commit passes the args first, which isn't how nbQA expects its arguments. I might need to make a breaking change to the api to get this to work, e.g.

nbqa --tool isort --files file.ipynb

rather than

nbqa isort file.ipynb

For now, either args: ["--profile=black"] or just using a configuration file to specify this option is what I'd suggest as a workaround

MarcoGorelli commented 2 years ago

closed by #732