Skip to content

Commit f974449

Browse files
otherJL0tony
authored andcommitted
Refactor window _info method
1 parent 4c54c80 commit f974449

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
@@ -74,22 +74,23 @@ def _info(self, *args):
7474
attrs = {"window_id": self._window_id}
7575

7676
# from https://github.com/serkanyersen/underscore.py
77-
def by(val, *args):
78-
for key, value in attrs.items():
77+
def by(val):
78+
for key in attrs.keys():
7979
try:
8080
if attrs[key] != val[key]:
8181
return False
8282
except KeyError:
8383
return False
84-
return True
84+
return True
8585

86-
ret = list(filter(by, self.server._windows))
86+
# TODO add type hint
87+
target_windows = list(filter(by, self.server._windows))
8788
# If a window_shell option was configured which results in
8889
# a short-lived process, the window id is @0. Use that instead of
8990
# self._window_id
90-
if len(ret) == 0 and self.server._windows[0]["window_id"] == "@0":
91-
ret = self.server._windows
92-
return ret[0]
91+
if len(target_windows) == 0 and self.server._windows[0]["window_id"] == "@0":
92+
target_windows = self.server._windows
93+
return target_windows[0]
9394

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

0 commit comments

Comments
 (0)