Skip to content

Commit 9cda65a

Browse files
committed
chore(ruff): Manual fixes for tmuxp/util.py
src/tmuxp/util.py:53:34: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` src/tmuxp/util.py:56:9: TRY300 Consider moving this statement to an `else` block src/tmuxp/util.py:59:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling src/tmuxp/util.py:59:13: TRY200 Use `raise from` to specify exception cause src/tmuxp/util.py:59:52: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` src/tmuxp/util.py:69:5: SIM102 Use a single `if` statement instead of nested `if` statements src/tmuxp/util.py:70:9: SIM102 Use a single `if` statement instead of nested `if` statements src/tmuxp/util.py:70:12: PTH110 `os.path.exists()` should be replaced by `Path.exists()` src/tmuxp/util.py:70:27: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()`
1 parent f66d652 commit 9cda65a

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

src/tmuxp/util.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ def run_before_script(
5050
stderr_str = "\n".join(list(filter(None, stderr_strlist))) # filter empty
5151

5252
raise exc.BeforeLoadScriptError(
53-
proc.returncode, os.path.abspath(script_file), stderr_str
53+
proc.returncode,
54+
os.path.abspath(script_file), # NOQA: PTH100
55+
stderr_str,
5456
)
55-
56-
return proc.returncode
57+
else:
58+
return proc.returncode
5759
except OSError as e:
5860
if e.errno == 2:
59-
raise exc.BeforeLoadScriptNotExists(e, os.path.abspath(script_file))
61+
raise exc.BeforeLoadScriptNotExists(
62+
e,
63+
os.path.abspath(script_file), # NOQA: PTH100
64+
) from e
6065
else:
6166
raise
6267

@@ -66,21 +71,23 @@ def oh_my_zsh_auto_title() -> None:
6671
6772
See: https://github.com/robbyrussell/oh-my-zsh/pull/257
6873
"""
69-
if "SHELL" in os.environ and "zsh" in os.environ.get("SHELL", ""):
70-
if os.path.exists(os.path.expanduser("~/.oh-my-zsh")):
71-
# oh-my-zsh exists
72-
if (
73-
"DISABLE_AUTO_TITLE" not in os.environ
74-
or os.environ.get("DISABLE_AUTO_TITLE") == "false"
75-
):
76-
print(
77-
"Please set:\n\n"
78-
"\texport DISABLE_AUTO_TITLE='true'\n\n"
79-
"in ~/.zshrc or where your zsh profile is stored.\n"
80-
'Remember the "export" at the beginning!\n\n'
81-
"Then create a new shell or type:\n\n"
82-
"\t$ source ~/.zshrc"
83-
)
74+
if (
75+
"SHELL" in os.environ
76+
and "zsh" in os.environ.get("SHELL", "")
77+
and os.path.exists(os.path.expanduser("~/.oh-my-zsh")) # NOQA PTH110, PTH111
78+
and (
79+
"DISABLE_AUTO_TITLE" not in os.environ
80+
or os.environ.get("DISABLE_AUTO_TITLE") == "false"
81+
)
82+
):
83+
print(
84+
"Please set:\n\n"
85+
"\texport DISABLE_AUTO_TITLE='true'\n\n"
86+
"in ~/.zshrc or where your zsh profile is stored.\n"
87+
'Remember the "export" at the beginning!\n\n'
88+
"Then create a new shell or type:\n\n"
89+
"\t$ source ~/.zshrc"
90+
)
8491

8592

8693
def get_current_pane(server: "Server") -> t.Optional["Pane"]:

0 commit comments

Comments
 (0)