basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

`redundant-expr` is annoying when using `assert_never`

Open DetachHead opened this issue 1 year ago • 0 comments

from __future__ import annotations

from typing import Literal, assert_never

foo: 1 | 2

if foo == 1:
    ...
elif foo == 2: # error: redundant-expr
    ...
else:
    assert_never(foo)

a possible solution is to just not report redundant-expr errors if there's an else statement, because you would otherwise get an unreachable error anyway if you aren't using assert_never

DetachHead avatar Apr 10 '24 00:04 DetachHead