Skip to content

Commit 081b139

Browse files
committed
Refactor window _info method
1 parent e9d67f4 commit 081b139

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

libtmux/window.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,23 @@ def _info(self, *args):
6868
attrs = {"window_id": self._window_id}
6969

7070
# from https://github.com/serkanyersen/underscore.py
71-
def by(val, *args):
72-
for key, value in attrs.items():
71+
def by(val):
72+
for key in attrs.keys():
7373
try:
7474
if attrs[key] != val[key]:
7575
return False
7676
except KeyError:
7777
return False
78-
return True
78+
return True
7979

80-
ret = list(filter(by, self.server._windows))
80+
# TODO add type hint
81+
target_windows = list(filter(by, self.server._windows))
8182
# If a window_shell option was configured which results in
8283
# a short-lived process, the window id is @0. Use that instead of
8384
# self._window_id
84-
if len(ret) == 0 and self.server._windows[0]["window_id"] == "@0":
85-
ret = self.server._windows
86-
return ret[0]
85+
if len(target_windows) == 0 and self.server._windows[0]["window_id"] == "@0":
86+
target_windows = self.server._windows
87+
return target_windows[0]
8788

8889
def cmd(self, cmd, *args, **kwargs):
8990
"""Return :meth:`Server.cmd` defaulting ``target_window`` as target.

0 commit comments

Comments
 (0)