-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code
Description
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
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-reachabilityDetecting unreachable codeDetecting unreachable code