<!-- If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the "Question and Help" form instead. --> **Bug Report** <!-- Note: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues --> **To Reproduce** ```python x = object() if isinstance(x, (int, str)): reveal_type(x) # Union[int, str] if isinstance(x, int): pass reveal_type(x) # object ``` **Expected Behavior** both types revealed as `Union[int, str]` **Actual Behavior** `object` from second type **Your Environment** - Mypy version used: latest master (0.820+dev.72ac2cee910ca61bfdf449217328b6d10b45d378) - Mypy command-line flags: none - Mypy configuration options from `mypy.ini` (and other config files): none - Python version used: 3.7.3 - Operating system and version: debian 10 based linux distro
Activity
JukkaL commentedon Mar 5, 2021
It looks like we should perhaps maintain a stack of narrowed down types (though I might be wrong).
erictraut commentedon Aug 12, 2023
This is another example of join vs union. It should probably be tagged as such.