You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, ...]")
fromtypingimportList, Tuple, TypeVarT=TypeVar("T") # or covariant, or contravariantdeff(a: Tuple[T, ...] = (None,)) ->List[T]: # Or Tuple[T], Set[T], etc.returnlist(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.
The text was updated successfully, but these errors were encountered:
Note that supporting this would require lower bounds for type variables (currently mypy supports only upper bounds). For None it may sound silly, but technically it is still needed. Current workaround is to use overloads, see the original issue.
I would expect mypy to understand that
(None,)
is a valid default forTuple[T, ...]
, but instead I getThis 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.The text was updated successfully, but these errors were encountered: