Skip to content

Commit 63055de

Browse files
committed
chore(util): Update typings
1 parent d9eb874 commit 63055de

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/tmuxp/util.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ def run_before_script(
3838
stdout=subprocess.PIPE,
3939
cwd=cwd,
4040
)
41-
for line in iter(proc.stdout.readline, b""):
42-
sys.stdout.write(console_to_str(line))
41+
if proc.stdout is not None:
42+
for line in iter(proc.stdout.readline, b""):
43+
sys.stdout.write(console_to_str(line))
4344
proc.wait()
4445

45-
if proc.returncode:
46+
if proc.returncode and proc.stderr is not None:
4647
stderr = proc.stderr.read()
4748
proc.stderr.close()
48-
stderr = console_to_str(stderr).split("\n")
49-
stderr = "\n".join(list(filter(None, stderr))) # filter empty
49+
stderr_strlist = console_to_str(stderr).split("\n")
50+
stderr_str = "\n".join(list(filter(None, stderr_strlist))) # filter empty
5051

5152
raise exc.BeforeLoadScriptError(
52-
proc.returncode, os.path.abspath(script_file), stderr
53+
proc.returncode, os.path.abspath(script_file), stderr_str
5354
)
5455

5556
return proc.returncode
@@ -89,6 +90,7 @@ def get_current_pane(server: "Server") -> t.Optional["Pane"]:
8990
return [p for p in server.panes if p.pane_id == os.getenv("TMUX_PANE")][0]
9091
except IndexError:
9192
pass
93+
return
9294

9395

9496
def get_session(
@@ -153,7 +155,7 @@ def get_pane(window: "Window", current_pane: t.Optional["Pane"] = None) -> "Pane
153155
pane = window.attached_pane # NOQA: F841
154156
except exc.TmuxpException as e:
155157
print(e)
156-
return
158+
return None
157159

158160
if pane is None:
159161
if current_pane:

0 commit comments

Comments
 (0)