Skip to content

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

@ThiefMaster

Description

@ThiefMaster

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.
``

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions