summaryrefslogtreecommitdiff
path: root/rq/utils.py
diff options
context:
space:
mode:
authorlowercase00 <21188280+lowercase00@users.noreply.github.com>2023-01-28 21:47:55 -0300
committerGitHub <noreply@github.com>2023-01-29 07:47:55 +0700
commit55f833ab6f0e5f9404cb64f4a824d1453929b7d6 (patch)
treeac6f90e116da91df66eedc261090079525e0ab58 /rq/utils.py
parentd90c00501e1dd1ad6f0483195d5911c37f76cd6f (diff)
downloadrq-55f833ab6f0e5f9404cb64f4a824d1453929b7d6.tar.gz
Moves the `compact` helper to `utils` (#1769)
* Moves the `compact` helper to `utils` There is a helper funcion that excludes `None` values from a list. This was being declared both in the Queue and in the worker. This centralizes this helper in the `utils` Importing * Fix Type Annotation
Diffstat (limited to 'rq/utils.py')
-rw-r--r--rq/utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/rq/utils.py b/rq/utils.py
index e347ec3..a9fbb1d 100644
--- a/rq/utils.py
+++ b/rq/utils.py
@@ -125,6 +125,18 @@ class ColorizingStreamHandler(logging.StreamHandler):
return message
+def compact(lst: t.List[t.Any]) -> t.List[t.Any]:
+ """Excludes `None` values from a list-like object.
+
+ Args:
+ lst (list): A list (or list-like) oject
+
+ Returns:
+ object (list): The list without None values
+ """
+ return [item for item in lst if item is not None]
+
+
def as_text(v):
if v is None:
return None