Coverage for src/remedapy/multiply.py: 86%

1 from collections.abc import Callable

2 from typing import TypeVar, overload

3

4 TNum = TypeVar('TNum', int, float)

5

6

7@overload

8 def multiply(a: int, /) -> Callable[[TNum], TNum]: ...

9

10

11@overload

12 def multiply(a: float, /) -> Callable[[int | float], float]: ...

13

14

15@overload

16 def multiply(a: int, b: TNum, /) -> TNum: ...

17

18

19@overload

20 def multiply(a: TNum, b: int, /) -> TNum: ...

21# rename to value, multiplyend

22 def multiply(

23 a: int | float,

24 b: int | float | None = None,

25 /,

26) -> int | float | Callable[[int | float], int | float] | Callable[[TNum], TNum]:

27 if b is None:

28 return lambda b: a * b

29 return a * b