Skip to content

Commit 1927410

Browse files
committed
chore(ruff): Manual fixes for cli/freeze.py
src/tmuxp/cli/freeze.py:109:13: TRY301 Abstract `raise` to an inner function src/tmuxp/cli/freeze.py:109:19: TRY003 Avoid specifying long messages outside the exception class src/tmuxp/cli/freeze.py:198:15: SIM115 Use context handler for opening files
1 parent 4b1425a commit 1927410

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/tmuxp/cli/freeze.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tmuxp.exc import TmuxpException
1111
from tmuxp.workspace.finders import get_workspace_dir
1212

13-
from .. import util
13+
from .. import exc, util
1414
from ..workspace import freezer
1515
from .utils import prompt, prompt_choices, prompt_yes_no
1616

@@ -106,7 +106,7 @@ def command_freeze(
106106
session = util.get_session(server)
107107

108108
if not session:
109-
raise TmuxpException("Session not found.")
109+
raise exc.SessionNotFound()
110110
except TmuxpException as e:
111111
print(e)
112112
return
@@ -195,9 +195,8 @@ def extract_workspace_format(
195195
destdir = os.path.dirname(dest)
196196
if not os.path.isdir(destdir):
197197
os.makedirs(destdir)
198-
buf = open(dest, "w")
199-
buf.write(workspace)
200-
buf.close()
198+
with open(dest, "w") as buf:
199+
buf.write(workspace)
201200

202201
if not args.quiet:
203202
print("Saved to %s." % dest)

0 commit comments

Comments
 (0)