Closed
Description
I would expect mypy to understand that (None,)
is a valid default for Tuple[T, ...]
, but instead I get
error: Incompatible default for argument "a"
(default has type "Tuple[None]", argument has type "Tuple[T, ...]")
from typing import List, Tuple, TypeVar
T = TypeVar("T") # or covariant, or contravariant
def f(a: Tuple[T, ...] = (None,)) -> List[T]: # Or Tuple[T], Set[T], etc.
return list(a)
This was actually found while working on HypothesisWorks/hypothesis#167, where the signature eventually desugars to (Callable[..., T], SearchStrategy[T]) -> SearchStrategy[Callable[..., T]]
, but the tuple-to-list example here has the same problem and is much easier to follow.
Metadata
Metadata
Assignees
Labels
No labels