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

Y062 doesn't account for nested literals #485

Open
tusharsadhwani opened this issue May 3, 2024 · 2 comments
Open

Y062 doesn't account for nested literals #485

tusharsadhwani opened this issue May 3, 2024 · 2 comments
Labels

Comments

@tusharsadhwani
Copy link

According to spec, Literal[X, Y] should be treated as Union[Literal[X], Literal[Y], which means nested Literals should be supported by type checkers.

Hence raising Y062 for cases like Literal[1, Literal[2, 1]] would make sense I believe.

@JelleZijlstra
Copy link
Collaborator

Seems like we also don't have a lint rule against Literal[A, Literal[B, C]], which should be replaced with Literal[A, B, C].

@tomasr8
Copy link
Contributor

tomasr8 commented May 24, 2024

One special case to consider (though an unlikely one) is Literal[1, Literal[1, 1]] where both inner 1s are considered duplicates for the parent Literal and the last 1 is a duplicate within the inner Literal as well

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

No branches or pull requests

3 participants