from typing import TypeVar
class X: pass
U = TypeVar('U', bound=None | X)
def project(projectable: U) -> U:
if projectable is None:
return None # MyPy claims this is unreachable!
return projectable
If warn-unreachable is enabled, then MyPy claims this is unreachable.