Skip to content

Commit c864745

Browse files
committed
!squash
1 parent ca0739f commit c864745

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

libtmux/session.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ def set_option(
414414
415415
Needs tests
416416
"""
417-
418417
if isinstance(value, bool) and value:
419418
value = "on"
420419
elif isinstance(value, bool) and not value:

libtmux/window.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ def show_window_option(
262262
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
263263
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
264264
"""
265-
266-
tmux_args = tuple()
265+
tmux_args: t.Tuple[t.Union[str, int], ...] = tuple()
267266

268267
if g:
269268
tmux_args += ("-g",)
@@ -275,15 +274,18 @@ def show_window_option(
275274
if len(cmd.stderr):
276275
handle_option_error(cmd.stderr[0])
277276

278-
if not len(cmd.stdout):
277+
window_options_output = cmd.stdout
278+
279+
if not len(window_options_output):
279280
return None
280281

281-
option = [shlex.split(item) for item in cmd.stdout][0]
282+
value_raw = [shlex.split(item) for item in window_options_output][0]
282283

283-
if option[1].isdigit():
284-
option = (option[0], int(option[1]))
284+
value: t.Union[str, int] = (
285+
int(value_raw[1]) if value_raw[1].isdigit() else value_raw[1]
286+
)
285287

286-
return option[1]
288+
return value
287289

288290
def rename_window(self, new_name: str) -> "Window":
289291
"""
@@ -364,7 +366,7 @@ def select_window(self) -> "Window":
364366
"""
365367
return self.session.select_window(self.index)
366368

367-
def select_pane(self, target_pane: int) -> t.Optional[Pane]:
369+
def select_pane(self, target_pane: t.Union[str, int]) -> t.Optional[Pane]:
368370
"""
369371
Return selected :class:`Pane` through ``$ tmux select-pane``.
370372
@@ -453,7 +455,7 @@ def split_window(
453455

454456
# '-t%s' % self.attached_pane.get('pane_id'),
455457
# 2013-10-18 LOOK AT THIS, rm'd it..
456-
tmux_args: t.Tuple = tuple()
458+
tmux_args: t.Tuple[str, ...] = tuple()
457459

458460
if target:
459461
tmux_args += ("-t%s" % target,)
@@ -481,23 +483,25 @@ def split_window(
481483
if shell:
482484
tmux_args += (shell,)
483485

484-
pane = self.cmd("split-window", *tmux_args)
486+
pane_cmd = self.cmd("split-window", *tmux_args)
485487

486488
# tmux < 1.7. This is added in 1.7.
487-
if pane.stderr:
488-
if "pane too small" in pane.stderr:
489-
raise exc.LibTmuxException(pane.stderr)
489+
if pane_cmd.stderr:
490+
if "pane too small" in pane_cmd.stderr:
491+
raise exc.LibTmuxException(pane_cmd.stderr)
490492

491-
raise exc.LibTmuxException(pane.stderr, self._info, self.panes)
492-
else:
493-
pane = pane.stdout[0]
493+
raise exc.LibTmuxException(pane_cmd.stderr, self._info, self.panes)
494+
495+
pane_output = pane_cmd.stdout[0]
494496

495-
pane = dict(zip(pformats, pane.split(formats.FORMAT_SEPARATOR)))
497+
pane_formatters = dict(
498+
zip(pformats, pane_output.split(formats.FORMAT_SEPARATOR))
499+
)
496500

497-
# clear up empty dict
498-
pane = {k: v for k, v in pane.items() if v}
501+
# Prune empty values
502+
pane_formatters_filtered = {k: v for k, v in pane_formatters.items() if v}
499503

500-
return Pane(window=self, **pane)
504+
return Pane(window=self, **pane_formatters_filtered)
501505

502506
@property
503507
def attached_pane(self) -> t.Optional[Pane]:

0 commit comments

Comments
 (0)