mypy
mypy copied to clipboard
(🐞) no error when can't able to infer type argument and becomes `Never`
# Some stub
from typing import TypeVar
T = TypeVar("T")
def something(x: T = ...) -> T:
"""x, the parameter for everything (formally Twitter)"""
# some other file
f: object
f = something()
reveal_type(f) # Never
if f:
print("hi") # unreachable
print("hi") # unreachable
We have an interesting array of bugs on display here, but most importantly I think, is that the call to something doesn't report that T can't be inferred.
Seeing as f is object here, I would expect T to be inferred as object