From 978c0913c886e881c14b561c68fe5383d6ce8a4d Mon Sep 17 00:00:00 2001 From: Ilya Konstantinov Date: Mon, 11 Jun 2018 19:50:56 -0700 Subject: [PATCH] Add stub for first (#2141) Reviewed by author in https://github.com/hynek/first/pull/22 --- third_party/2and3/first.pyi | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 third_party/2and3/first.pyi diff --git a/third_party/2and3/first.pyi b/third_party/2and3/first.pyi new file mode 100644 index 000000000..f03f3a35b --- /dev/null +++ b/third_party/2and3/first.pyi @@ -0,0 +1,13 @@ +from typing import Any, Callable, Iterable, Optional, overload, TypeVar, Union + +_T = TypeVar('_T') +_S = TypeVar('_S') + +@overload +def first(iterable: Iterable[_T]) -> Optional[_T]: ... +@overload +def first(iterable: Iterable[_T], default: _S) -> Union[_T, _S]: ... +@overload +def first(iterable: Iterable[_T], default: _S, key: Optional[Callable[[_T], Any]]) -> Union[_T, _S]: ... +@overload +def first(iterable: Iterable[_T], *, key: Optional[Callable[[_T], Any]]) -> Optional[_T]: ...