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

1 import random

2 import string

3 from collections.abc import Callable

4 from typing import overload

5

6 from remedapy.decorator import make_data_last

7

8

9@overload

10 def random_string(length: int, /) -> str: ...

11

12

13@overload

14 def random_string() -> Callable[[int], str]: ...

15

16

17@make_data_last

18 def random_string(length: int, /) -> str:

19 characters = string.ascii_letters + string.digits

20 return ''.join(random.choices(characters, k=length))