Coverage for src/makefun/_main_py36_and_higher.py: 90%

8 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-09-26 12:39 +0000

1# Authors: Sylvain MARIE <sylvain.marie@se.com> 

2# + All contributors to <https://github.com/smarie/python-makefun> 

3# 

4# License: 3-clause BSD, <https://github.com/smarie/python-makefun/blob/master/LICENSE> 

5from itertools import chain 

6 

7from makefun.main import wraps 

8 

9 

10def make_partial_using_async_for_in_yield(new_sig, f, *preset_pos_args, **preset_kwargs): 

11 """ 

12 Makes a 'partial' when f is a async generator and python is new enough to support `async for v in f(): yield v` 

13 

14 :param new_sig: 

15 :param f: 

16 :param presets: 

17 :return: 

18 """ 

19 

20 @wraps(f, new_sig=new_sig) 

21 async def partial_f(*args, **kwargs): 

22 kwargs.update(preset_kwargs) 

23 async for v in f(*chain(preset_pos_args, args), **kwargs): 23 ↛ exitline 23 didn't return from function 'partial_f', because the loop on line 23 didn't complete

24 yield v 

25 

26 return partial_f