Coverage for src/remedapy/take.py: 100%

1 from collections.abc import Callable, Iterable

2 from typing import TypeVar, overload

3

4 from .decorator import make_data_last

5

6 T = TypeVar('T')

7

8

9@overload

10 def take(it: Iterable[T], n: int, /) -> Iterable[T]: ...

11

12

13@overload

14 def take(n: int, /) -> Callable[[Iterable[T]], Iterable[T]]: ...

15

16

17@make_data_last

18 def take(it: Iterable[T], n: int, /) -> Iterable[T]:

19 for i, x in enumerate(it):

20 if i >= n:

21 break

22 yield x