Skip to content

Commit 19a678e

Browse files
Remove unnecessary comprehension
1 parent 1bfc966 commit 19a678e

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

labthings/core/lock.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ def acquire(self, blocking=True, timeout=None):
8383
timeout = self.timeout
8484

8585
lock_all = all(
86-
[
87-
lock.acquire(blocking=blocking, timeout=timeout, _strict=False)
86+
lock.acquire(blocking=blocking, timeout=timeout, _strict=False)
8887
for lock in self.locks
89-
]
9088
)
9189

9290
if not lock_all:
@@ -103,7 +101,7 @@ def __exit__(self, *args):
103101

104102
def release(self):
105103
# If not all child locks are owner by caller
106-
if not all([owner is getcurrent() for owner in self._owner]):
104+
if not all(owner is getcurrent() for owner in self._owner):
107105
raise RuntimeError("cannot release un-acquired lock")
108106
for lock in self.locks:
109107
if lock.locked():
@@ -115,7 +113,7 @@ def _emergency_release(self):
115113
lock.release()
116114

117115
def locked(self):
118-
return any([lock.locked() for lock in self.locks])
116+
return any(lock.locked() for lock in self.locks)
119117

120118
@property
121119
def _owner(self):
@@ -127,4 +125,4 @@ def _owner(self, new_owner):
127125
lock._owner = new_owner
128126

129127
def _is_owned(self):
130-
return all([lock._is_owned() for lock in self.locks])
128+
return all(lock._is_owned() for lock in self.locks)

labthings/server/labthing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _complete_url(self, url_part, registration_prefix):
233233
blueprint. Generally speaking, BlueprintSetupState.url_prefix
234234
"""
235235
parts = [self.url_prefix, registration_prefix, url_part]
236-
u = "".join([clean_url_string(part) for part in parts if part])
236+
u = "".join(clean_url_string(part) for part in parts if part)
237237
return u if u else "/"
238238

239239
def add_view(self, resource, *urls, endpoint=None, **kwargs):

labthings/server/spec/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def tag_spec(obj, tags, add_group: bool = True):
2828
obj.__apispec__["tags"] = set()
2929

3030
if isinstance(tags, set) or isinstance(tags, list):
31-
if not all([isinstance(e, str) for e in tags]):
31+
if not all(isinstance(e, str) for e in tags):
3232
raise TypeError("All tags must be strings")
3333
obj.__apispec__["tags"] = obj.__apispec__["tags"].union(tags)
3434
elif isinstance(tags, str):

tests/test_core_tasks_pool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def test_update_task_progress_main_thread():
5050

5151

5252
def test_tasks_list():
53-
assert all([isinstance(task_obj, gevent.Greenlet) for task_obj in tasks.tasks()])
53+
assert all(isinstance(task_obj, gevent.Greenlet) for task_obj in tasks.tasks())
5454

5555

5656
def test_tasks_dict():
5757
assert all(
58-
[isinstance(task_obj, gevent.Greenlet) for task_obj in tasks.to_dict().values()]
58+
isinstance(task_obj, gevent.Greenlet) for task_obj in tasks.to_dict().values()
5959
)
6060

61-
assert all([k == str(t.id) for k, t in tasks.to_dict().items()])
61+
assert all(k == str(t.id) for k, t in tasks.to_dict().items())
6262

6363

6464
def test_task_states():

0 commit comments

Comments
 (0)