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

Incorrect ignore logic #4916

Closed
dcragusa opened this issue Jun 7, 2023 · 4 comments · Fixed by #4917
Closed

Incorrect ignore logic #4916

dcragusa opened this issue Jun 7, 2023 · 4 comments · Fixed by #4917
Labels
question Asking for support or clarification

Comments

@dcragusa
Copy link

dcragusa commented Jun 7, 2023

Ruff version ruff 0.0.271.

pyproject.toml:

[tool.ruff]
select = ["ALL"]

test.py:

"""Module to test ruff ignores."""
print("test")
a = 20  # TODO

Command run: ruff . in project directory.

Output seen:

test.py:2:1: T201 `print` found
test.py:3:11: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...`
test.py:3:11: TD004 Missing colon in TODO
test.py:3:11: TD005 Missing issue description after `TODO`
test.py:3:11: TD003 Missing issue link on the line following this TODO
test.py:3:11: T002 Line contains TODO

This is fine. Now we add ignore = ["T20"] to the toml file. Output seen:

test.py:3:11: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...`
test.py:3:11: TD004 Missing colon in TODO
test.py:3:11: TD005 Missing issue description after `TODO`
test.py:3:11: TD003 Missing issue link on the line following this TODO
test.py:3:11: T002 Line contains TODO

This is also fine. But if we change it to ignore = ["T"], we see:

test.py:3:11: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...`
test.py:3:11: TD004 Missing colon in TODO
test.py:3:11: TD005 Missing issue description after `TODO`
test.py:3:11: TD003 Missing issue link on the line following this TODO
test.py:3:11: T002 Line contains TODO

Instead we should be seeing:

test.py:2:1: T201 `print` found
test.py:3:11: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...`
test.py:3:11: TD004 Missing colon in TODO
test.py:3:11: TD005 Missing issue description after `TODO`
test.py:3:11: TD003 Missing issue link on the line following this TODO

Ruff is confusing T and T20.

@charliermarsh
Copy link
Member

If we change it to ignore = ["T"], should we not be seeing:

test.py:3:11: TD002 Missing author in TODO; try: `# TODO(<author_name>): ...`
test.py:3:11: TD004 Missing colon in TODO
test.py:3:11: TD005 Missing issue description after `TODO`
test.py:3:11: TD003 Missing issue link on the line following this TODO

(Your final cell included test.py:2:1: T201 print found at the top?)

@charliermarsh charliermarsh added the question Asking for support or clarification label Jun 7, 2023
@dcragusa
Copy link
Author

dcragusa commented Jun 7, 2023

I want to ignore the T rules though, not the T20 rules as well.

@dcragusa
Copy link
Author

dcragusa commented Jun 7, 2023

I've double checked, with ignore = ["T"] we still see the T002 rule found.

@charliermarsh
Copy link
Member

T should select T201 and T002, since they both belong under the T prefix. So the bug here is that T002 isn't being ignored when ignore = ["T"] is specified.

If you want to ignore the TODO rules, I'd recommend ignore = ["T0"], or something that differentiates from the T20 rules, which you want to keep. T alone isn't sufficiently discriminant.

As an aside, I'll likely reindex T002 under a more precise prefix in the next release. It was an oversight to reuse T like this, I didn't catch it in the review.

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

Successfully merging a pull request may close this issue.

2 participants