report an error on unnecessary conditions
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
```py
def fn(value: int):
if isinstance(value, int): # error
print(1)
```
this is comparable to reporting unreachable code (although it doesn't seem to work in cases like this anyway, see #3689), but the benefit of reporting an error on the condition is that it still warns you even if there's no other branch with unreachable code in it.
pyright has several rules for these:
- `reportUnnecessaryIsInstance`
- ~`reportUnnecessaryComparison`~ - covered by [`incompatible-comparison`](https://pyrefly.org/en/docs/error-kinds/#incompatible-comparison)
- `reportUnnecessaryContains`
- `reportAssertAlwaysTrue`
but ideally it should just be a generic rule that detects any unneccessary condition
Contributor guide
Assessment
This issue has not been assessed yet.