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

Error with nbqa-ruff hook #861

Closed Anu-Ra-g closed 2 months ago

Anu-Ra-g commented 3 months ago

I'm getting an error, while running this hook

- repo: https://github.com/nbQA-dev/nbQA
    rev: 1.7.0
    hooks:
      - id: nbqa-ruff
        args: ["--fix", "--ignore=E402"]
      - id: nbqa-isort
        args: ["--profile=black"]
        additional_dependencies: [isort==5.6.4]
      - id: nbqa-black
      - id: nbqa-pyupgrade
        args: ["--py37-plus"]

  - repo: https://github.com/charliermarsh/ruff-pre-commit
    rev: "v0.0.243"
    hooks:
      - id: ruff
        args: ["--fix"]

I'm getting,

nbqa-ruff................................................................Failed
- hook id: nbqa-ruff
- exit code: 1

error: `ruff <path>` has been removed. Use `ruff check <path>` instead.

With the check argument, I'm getting this,

nbqa-ruff................................................................Failed
- hook id: nbqa-ruff
- exit code: 1

No such file or directory: check

I guess this is happening due to lack of support for the new version of ruff?

MarcoGorelli commented 2 months ago

thanks @Anu-Ra-g for the report

yup, this

https://github.com/nbQA-dev/nbQA/blob/872d6d5d7557cb69594174ce4bc8d04bae0d42ab/.pre-commit-hooks.yaml#L89-L96

needs updating to use ruff check

maybe we need nbqa-ruff-check and nbqa-ruff-format

Anu-Ra-g commented 2 months ago

@MarcoGorelli I'd like to try to solve this issue can refer me to the files to which I should look at?

MarcoGorelli commented 2 months ago

thanks! just nbQA/.pre-commit-hooks.yaml should be enough, make two new hooks:

and for the current nbqa-ruff one, make entry nbqa "ruff check" (for backwards compatibility)

thanks!

Anu-Ra-g commented 2 months ago

Is this okay?

- id: nbqa-ruff
  name: nbqa-ruff
  description: Run 'ruff check' on a Jupyter Notebook  # backwards compatiblity
  entry: nbqa "ruff check"
  language: python
  additional_dependencies: [ruff]
  require_serial: true
  types_or: [jupyter, markdown]
- id: nbqa-ruff-check
  name: nbqa-ruff-check
  description: Run 'ruff check' on a Jupyter Notebook
  entry: nbqa ruff check
  language: python
  additional_dependencies: [ruff]
  require_serial: true
  types_or: [jupyter, markdown]
- id: nbqa-ruff-format
  name: nbqa-ruff-format
  description: Run 'ruff format' on a Jupyter Notebook
  entry: nbqa ruff format
  language: python
  additional_dependencies: [ruff]
  require_serial: true
  types_or: [jupyter, markdown]
MarcoGorelli commented 2 months ago

nbqa ruff check should be nbqa "ruff check", same for format