Bug Report
If the expression for an if statement is always true, then it is obviously redundant.
To Reproduce
from typing import Literal
class X:
def __bool__(self) -> Literal[True]:
return True
if X():
print("blah!")
Expected Behavior
Error on if X()
Actual Behavior
No error
Your Environment
- Mypy version used: 1.17.1
- Mypy command-line flags:
--enable-error-code=redundant-expr
- Mypy configuration options from
mypy.ini (and other config files): N/A
- Python version used: 3.14
Bug Report
If the expression for an if statement is always true, then it is obviously redundant.
To Reproduce
Expected Behavior
Error on
if X()Actual Behavior
No error
Your Environment
--enable-error-code=redundant-exprmypy.ini(and other config files): N/A