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 appears to ignore per-file-ignores in pyproject.toml #823

Closed
paddyroddy opened this issue Jun 5, 2023 · 3 comments
Closed

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

paddyroddy opened this issue Jun 5, 2023 · 3 comments

Comments

@paddyroddy
Copy link

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

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

Yep that works!

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

@MarcoGorelli
Copy link
Collaborator

Cool, thanks! Closing then

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

2 participants