-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
tyMulti-file analysis & type inferenceMulti-file analysis & type inference
Milestone
Description
This does not type check, but it should:
def union_param[T](x: T | None) -> T:
if x is None:
raise ValueError("don't give me that none")
return x # bogus error: expected T, found T & ~NoneThe equivalent where we replace T with a concrete type, does type check:
def union_param(x: int | None) -> int:
if x is None:
raise ValueError("don't give me that none")
return xPlacing this in alpha milestone because I've run into it already several times, I think it will be a common source of false positives in generic functions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
tyMulti-file analysis & type inferenceMulti-file analysis & type inference