flake8-pyi icon indicating copy to clipboard operation
flake8-pyi copied to clipboard

`Y062` doesn't account for nested literals

Open tusharsadhwani opened this issue 1 year ago • 2 comments

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.

tusharsadhwani avatar May 03 '24 20:05 tusharsadhwani

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

JelleZijlstra avatar May 03 '24 20:05 JelleZijlstra

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

tomasr8 avatar May 24 '24 08:05 tomasr8