Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with nbqa-ruff hook #861

Closed
Anu-Ra-g opened this issue Aug 25, 2024 · 5 comments · Fixed by #862
Closed

Error with nbqa-ruff hook #861

Anu-Ra-g opened this issue Aug 25, 2024 · 5 comments · Fixed by #862

Comments

@Anu-Ra-g
Copy link
Contributor

Anu-Ra-g commented Aug 25, 2024

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
Copy link
Collaborator

thanks @Anu-Ra-g for the report

yup, this

- id: nbqa-ruff
name: nbqa-ruff
description: Run 'ruff' on a Jupyter Notebook
entry: nbqa ruff
language: python
additional_dependencies: [ruff]
require_serial: true
types_or: [jupyter, markdown]

needs updating to use ruff check

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

@Anu-Ra-g
Copy link
Contributor Author

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

@MarcoGorelli
Copy link
Collaborator

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

  • nbqa-ruff-check
  • nbqa-ruff-format

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

thanks!

@Anu-Ra-g
Copy link
Contributor Author

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants