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

nbqa-ruff-check hooks do not take into account pyproject.toml #868

Open
martibosch opened this issue Sep 11, 2024 · 2 comments
Open

nbqa-ruff-check hooks do not take into account pyproject.toml #868

martibosch opened this issue Sep 11, 2024 · 2 comments

Comments

@martibosch
Copy link

I have the following setup with nbqa 1.9.0 and ruff 0.6.4:

# pyproject.toml
[tool.nbqa.addopts]
ruff = [
    "--ignore=D,I",
]
# .pre-commit-config.yaml
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.9.0
    hooks:
      - id: nbqa-ruff-check
        args: ["--fix"]
      - id: nbqa-ruff-format
      - id: nbqa-ruff-check

Nonetheless, pre-commit hooks still raise D100 and I001 in my notebooks. A workaround is to use:

# .pre-commit-config.yaml
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.9.0
    hooks:
      - id: nbqa-ruff-check
        args: ["--fix", "--ignore=D,I"]
      - id: nbqa-ruff-format
      - id: nbqa-ruff-check
        args: ["--ignore=D,I"]

However, this requires me to "duplicate" the configuration. Is there any way to make nbqa take pyproject.toml into account with the new nbqa-ruff-check hook?

@MarcoGorelli
Copy link
Collaborator

thanks for the report 🙏 investigations + fixes are welcome

@minrk
Copy link
Contributor

minrk commented Oct 30, 2024

@martibosch I think you should have ruff check instead of ruff to affect nbqa-ruff-check:

[tool.nbqa.addopts]
"ruff check" = [
    "--ignore=D,I",
]

or perhaps better to configure ruff directly:

[tool.ruff.lint]
ignore = ["D", "I"]

or if this is in nbqa config in order to only affect notebooks, after #870 you should be able to do:

[tool.ruff.lint.per-file-ignores]
"**/*nbqa_ipynb.py" = ["D", "I"]

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

No branches or pull requests

3 participants