mypy icon indicating copy to clipboard operation
mypy copied to clipboard

(🐞) no error when can't able to infer type argument and becomes `Never`

Open KotlinIsland opened this issue 1 year ago • 0 comments

# 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

KotlinIsland avatar Jun 21 '24 03:06 KotlinIsland