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 (incorrectly-parenthesized-tuple-in-subscript) - false positive on types #12773

Closed
DetachHead opened this issue Aug 9, 2024 · 4 comments

Comments

@DetachHead
Copy link

# ruff.toml
[lint.ruff]
parenthesize-tuple-in-subscript = true
foo = dict[str, str] = {} # error: Use parentheses for tuples in subscripts.

subscripts have a completely different meaning in type annotations, and the fact that the arguments to dict are a tuple is an implementation detail of the syntax, so i don't think this rule should apply to them.

@dhruvmanila
Copy link
Member

I think this makes sense. I wonder if generics should be accounted here as well. For example:

class Foo(Generic[T1, T2]):
	...

@AlexWaygood @MichaReiser Any thoughts?

@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Aug 9, 2024
@DetachHead
Copy link
Author

the same applies in that case too imo, because the subscript syntax is being used to represent generics

@dhruvmanila
Copy link
Member

Oh, I think this is covered by #12758 and a fix for it is already up #12762.

@dhruvmanila
Copy link
Member

(Merging this with #12758)

@dhruvmanila dhruvmanila closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
@dhruvmanila dhruvmanila added duplicate and removed rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants