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

Add example of per-file-ignores in TOML to Readme #486

Closed
tgross35 opened this issue Oct 27, 2022 · 4 comments · Fixed by #488
Closed

Add example of per-file-ignores in TOML to Readme #486

tgross35 opened this issue Oct 27, 2022 · 4 comments · Fixed by #488

Comments

@tgross35
Copy link
Contributor

tgross35 commented Oct 27, 2022

Hello,

It took quite a few attempts to get the syntax right for configuring per-file-ignores in toml. Would you be able to add a quick example to the readme to help guide usage?

[tool.ruff]
per-file-ignores = [
    "**/__init__.py:F401",
    "directory/file.py:F401"
]

Side note - for toml configuration, could you consider allowing whitespace after the colon? "**/__init__.py: F401" is ever so slightly more readable, and matches the flake8 ini config a little bit closer.

Alternatively, it could be nice to be able to specify ignores in a more toml-y way

[tools.ruff.per-file-ignores]
"**/__init__.py" = ["F401",  "D100"]
"directory/file.py" = ["F401", "C409",  "B014"]

# or the other way around
[tools.ruff.per-file-ignores]
F401 = [
    "**/__init__.py",
    "directory/file.py"
]
@charliermarsh
Copy link
Member

Good suggestions all around! I haven't changed the actual syntax (though I do like the suggestion)... though for now I went ahead and (1) supported whitespace as requested, and (2) added an example to the README.

As an aside, you should be able to do:

[tool.ruff]
per-file-ignores = [
    "__init__.py:F401",  # No need for ** -- this should match any file named `__init__.py`
    "directory/file.py:F401"
]

@tgross35
Copy link
Contributor Author

Awesome! Thanks for the super quick update

@charliermarsh
Copy link
Member

Always!

@charliermarsh
Copy link
Member

(Going out in v0.0.86, which is building now.)

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