(🎁) `redundant-expression` doesn't report in `else` branch when both sides are narrowed
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
def foo() -> bool:
return None == None
1 == 1
True == False
These codes show no warning about an always true check.
mypy in real life 😳
class Thing:
thing: str | None
def something(self, that: Thing) -> bool:
if self.thing is not None or that.thing is not None:
return True
else:
return self.thing == that.thing # no error, despite None == None
Would be nice if mypy could report on this code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the supplied foo and Thing examples as minimal reproductions, then run mypy to confirm the missing diagnostic in the else branch. Trace the narrowing and redundant-expression checks involved; done means the shown always-true comparisons are reported without regressing valid narrowing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100