Open
Description
The motivation is really uncompelling. It describes what intersections do, but not why we need them. I think it would be better to dig through the mypy issues to find various problems that require intersection to solve them and present them under motivation.
For example, this one: python/mypy#9424:
from typing import Optional, TypeVar
U = TypeVar('U', bound=Optional[int])
def f(u: U) -> U:
if u is None:
return None
assert isinstance(u, int) # removing this line causes it to pass.
return u
works with working intersections since u
will have static type int & U
.
Metadata
Metadata
Assignees
Labels
No labels