Coverage for src\zapy\utils\functools.py: 74%

21 statements  

« prev     ^ index     » next       coverage.py v7.3.4, created at 2023-12-20 14:17 -0500

1async def empty_function(*args): 

2 if len(args) == 0: 2 ↛ 3line 2 didn't jump to line 3, because the condition on line 2 was never true

3 return None 

4 elif len(args) == 1: 4 ↛ 7line 4 didn't jump to line 7, because the condition on line 4 was never false

5 return args[0] 

6 else: 

7 return args 

8 

9def call_with_signature(function, *args, kwargs): 

10 import inspect 

11 

12 sig = inspect.signature(function) 

13 my_args = list(args) 

14 my_kwargs = dict() 

15 args_tuples = list(sig.parameters.items()) 

16 for k , v in args_tuples[len(my_args):]: 

17 cls = v.annotation 

18 if inspect.Signature.empty == cls: 18 ↛ 19line 18 didn't jump to line 19, because the condition on line 18 was never true

19 raise ValueError(f"Undefined type for '{k}' argument on method '{function.__name__}'") 

20 if cls not in kwargs: 20 ↛ 21line 20 didn't jump to line 21, because the condition on line 20 was never true

21 raise ValueError(f"Invalid type of {cls} for argument '{k}' on method '{function.__name__}'") 

22 value = kwargs.get(cls) 

23 my_kwargs[k] = value 

24 return function(*my_args, **my_kwargs)