`allow-redefinition` should perform exhaustive branch analysis
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
def func(item: int) -> None:
print(item)
if True:
item = "amogus"
else:
item = "amogus"
main.py:3: error: Incompatible types in assignment (expression has type "str", variable has type "int")
In this snipped item is exhaustively redefined to str. I think it would be good if mypy could pick up on that.
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
Start by reproducing the example with mypy and trace the allow-redefinition handling through the branch-analysis code. Identify how exhaustive if branches are represented and add coverage showing that identical redefinitions in both branches are accepted; done means the example no longer reports the incompatible assignment while non-exhaustive cases retain their checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100