From 6617b0f1a6799c94b13d6b4b03c1f91d9ddeacb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <pmaslanka@smok.co>
Date: Fri, 24 Sep 2021 15:25:08 +0200
Subject: [PATCH] v2.17.21

---
 satella/random.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/satella/random.py b/satella/random.py
index ebafc123..ba42308d 100644
--- a/satella/random.py
+++ b/satella/random.py
@@ -1,3 +1,4 @@
+import typing as tp
 import os
 import random
 import typing as tp
@@ -8,22 +9,27 @@ __all__ = ['shuffle_together', 'random_binary', 'random_word']
 from satella.coding.typing import T
 
 
-def random_word(length: int, choice: T = string.ascii_lowercase,
-                join_fun: tp.Callable[[T, ...], T] = lambda *args: ''.join(args)):
+def random_word(length: int, choice: tp.Sequence[T] = string.ascii_lowercase,
+                join_fun: tp.Callable[[tp.List[T]], T] = lambda args: ''.join(args)) -> \
+        tp.Sequence[T]:
     """
     Build and return a random word of provided length.
 
     The word will be built by calling join_fun with length of arguments picked
     at random from choice.
 
+    Best used with strings. Provide a word length, a string to choose from as choice (defaults
+    to string.ascii_lowercase). Will return by default a string (which coincidentally
+    happens to be a sequence of strings, albeit one-character ones).
+
     :param length: length of the word
     :param choice: a range of characters to use. By default is string.ascii_lowercase
-    :param join_fun: an argument to be called with randomly picked characters as *args.
+    :param join_fun: an argument to be called with a list of randomly picked values.
         Defaults to ''.join(args), so your T must be a string. If you're passing a
         different type, remember to alter this function because the default one expects strings!
     :return: a random word
     """
-    return join_fun(*(random.choice(choice) for _ in range(length)))
+    return join_fun([random.choice(choice) for _ in range(length)])
 
 
 def random_binary(length: int) -> bytes:
-- 
GitLab