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

`nbqa-ruff` appears to ignore `per-file-ignores` in `pyproject.toml` #823

Closed paddyroddy closed 1 year ago

paddyroddy commented 1 year ago

I'm running the nbqa-ruff hook on a notebook which has some print and assert statements. From per-file-ignores these should be ignored, yet they are not. If I move those same rules into ignore then it works fine. Is there a reason why per-file-ignores isn't respected?

.pre-commit-config.yaml

repos:
  - repo: https://github.com/nbQA-dev/nbQA
    rev: 1.7.0
    hooks:
      - id: nbqa-ruff

pyproject.toml

[tool.ruff]
fix = true
force-exclude = true
per-file-ignores = {"*.ipynb" = [
    "S101",
    "T201",
]}
select = [
    "S",
    "T",
]
MarcoGorelli commented 1 year ago

Hey - I presume it's because the notebooks get converted to temporary python files, so the extension changes

Could you glob them some other way, like notebooks/* ?

paddyroddy commented 1 year ago

Yep that works!

[tool.ruff]
fix = true
force-exclude = true
per-file-ignores = {"name-of-notebook*" = [
    "S101",
    "T201",
]}
select = [
    "S",
    "T",
]
MarcoGorelli commented 1 year ago

Cool, thanks! Closing then