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

RUF031 with parenthesize-tuple-in-subscript = true should ignore type annotations #12758

Closed
ThiefMaster opened this issue Aug 8, 2024 · 0 comments · Fixed by #12762
Closed
Assignees
Labels
bug Something isn't working

Comments

@ThiefMaster
Copy link
Contributor

Feels like a bug to me that this applies to type annotations. In case of dict keys it's a very nice rule to make it clear that you have a tuple key, but for type annotations it feels pretty noisy/ugly...

$ ruff version
ruff 0.5.7

$ cat test.py
bar = {}
bar[('hello', 'world')] = None
foo: tuple[str, str] | None = None

$ ruff check --isolated --select RUF031 --config 'lint.ruff.parenthesize-tuple-in-subscript = true' --preview --no-cache test.py
test.py:3:12: RUF031 [*] Use parentheses for tuples in subscripts.
  |
1 | bar = {}
2 | bar[('hello', 'world')] = None
3 | foo: tuple[str, str] | None = None
  |            ^^^^^^^^ RUF031
  |
  = help: Parenthesize the tuple.

Found 1 error.
[*] 1 fixable with the `--fix` option.
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants