Skip to content
Snippets Groups Projects
Commit 50d31873 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

fixed typing issue in `choose` and `choose_one`

parent a5a0df2b
No related branches found
No related tags found
No related merge requests found
# v2.11.10
* added `make_list`
* fixed typing issue in `choose` and `choose_one`
__version__ = '2.11.10_a2'
__version__ = '2.11.10_a3'
import typing as tp
T = tp.TypeVar('T')
IteratorOrIterable = tp.Union[tp.Iterator[T], tp.Iterable[T]]
IteratorOrIterable = tp.Union[tp.Iterator, tp.Iterable]
def choose_one(filter_fun: tp.Callable[[T], bool], iterable: IteratorOrIterable) -> T:
def choose_one(filter_fun: tp.Callable[[tp.Any], bool], iterable: IteratorOrIterable) -> tp.Any:
"""
Syntactic sugar for
>>> choose(filter_fun, iterable, True)
>>> choose(filter_fun, iterable, check_multiple=True)
This exhausts the iterable.
:param filter_fun: function that returns bool on the single value
:param iterable: iterable to examine
......@@ -18,8 +19,8 @@ def choose_one(filter_fun: tp.Callable[[T], bool], iterable: IteratorOrIterable)
return choose(filter_fun, iterable, True)
def choose(filter_fun: tp.Callable[[T], bool], iterable: IteratorOrIterable,
check_multiple: bool = False) -> T:
def choose(filter_fun: tp.Callable[[tp.Any], bool], iterable: IteratorOrIterable,
check_multiple: bool = False) -> tp.Any:
"""
Return a single value that exists in given iterable.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment