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
Hi everyone, I'm trying to add type annotations for a third_party module, namely more_itertools. The function I'm having issues with is first_true, which is defined as
@srittau It would be great if you could add a link to the tracking issue for "the mypy team is planning to add support for a feature like this ("final types") soon."
Hi everyone, I'm trying to add type annotations for a third_party module, namely
more_itertools
. The function I'm having issues with isfirst_true
, which is defined asThis means that the return type would be either
Union[T, bool]
orUnion[T, U]
when there's an explicit default.The problem is that in the case of an implicit default, the pattern
would not work as inside the if,
element
could still beTrue
.What I would like is to signal that the return type is either
T
or the valueFalse
, is there any idiom to do that?Note that the same is true for builtin functions like
next
. Seehttps://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L862
ps: I know this would be solved if the API changed to have
default=None
instead.The text was updated successfully, but these errors were encountered: