Feature
Unreachability should be checked for constrained type vars.
Pitch
It would be nice if this raised an error when run with --warn-unreachable:
from typing import TypeVar
U = TypeVar('U', int, str)
def f(u: U) -> U:
if u is None:
print("whoa!!")
return u
To implement this feature, I think we need to store the spans of unreachability for each run, then find the intersection. I thought for a while that we could just treat constrained type variables as if they were bound to the union of constraints, but things like #9424 will happen for things that aren't final (unlike None).
Feature
Unreachability should be checked for constrained type vars.
Pitch
It would be nice if this raised an error when run with
--warn-unreachable:To implement this feature, I think we need to store the spans of unreachability for each run, then find the intersection. I thought for a while that we could just treat constrained type variables as if they were bound to the union of constraints, but things like #9424 will happen for things that aren't final (unlike
None).