Skip to content

Commit 2094c5a

Browse files
authored
Bump dev dependencies, including ruff 0.4.2, f-string tweaks (#540)
2 parents 959c55b + f8d17a6 commit 2094c5a

File tree

11 files changed

+147
-134
lines changed

11 files changed

+147
-134
lines changed

CHANGES

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ $ pip install --user --upgrade --pre libtmux
1515

1616
<!-- To maintainers and contributors: Please add notes for the forthcoming version above -->
1717

18+
### Development
19+
20+
- Code quality: Use f-strings in more places (#540)
21+
22+
via [ruff 0.4.2](https://github.com/astral-sh/ruff/blob/v0.4.2/CHANGELOG.md).
23+
1824
## libtmux 0.37.0 (04-21-2024)
1925

2026
_Maintenance only, no bug fixes or new features_

docs/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
project = about["__title__"]
5959
project_copyright = about["__copyright__"]
6060

61-
version = "%s" % (".".join(about["__version__"].split("."))[:2])
62-
release = "%s" % (about["__version__"])
61+
version = "{}".format(".".join(about["__version__"].split("."))[:2])
62+
release = "{}".format(about["__version__"])
6363

6464
exclude_patterns = ["_build"]
6565

poetry.lock

+115-115
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libtmux/common.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def set_environment(self, name: str, value: str) -> None:
6565
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
6666
else cmd.stderr
6767
)
68-
raise ValueError("tmux set-environment stderr: %s" % cmd.stderr)
68+
msg = f"tmux set-environment stderr: {cmd.stderr}"
69+
raise ValueError(msg)
6970

7071
def unset_environment(self, name: str) -> None:
7172
"""Unset environment variable ``$ tmux set-environment -u <name>``.
@@ -88,7 +89,8 @@ def unset_environment(self, name: str) -> None:
8889
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
8990
else cmd.stderr
9091
)
91-
raise ValueError("tmux set-environment stderr: %s" % cmd.stderr)
92+
msg = f"tmux set-environment stderr: {cmd.stderr}"
93+
raise ValueError(msg)
9294

9395
def remove_environment(self, name: str) -> None:
9496
"""Remove environment variable ``$ tmux set-environment -r <name>``.
@@ -111,7 +113,8 @@ def remove_environment(self, name: str) -> None:
111113
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
112114
else cmd.stderr
113115
)
114-
raise ValueError("tmux set-environment stderr: %s" % cmd.stderr)
116+
msg = f"tmux set-environment stderr: {cmd.stderr}"
117+
raise ValueError(msg)
115118

116119
def show_environment(self) -> Dict[str, Union[bool, str]]:
117120
"""Show environment ``$ tmux show-environment -t [session]``.
@@ -278,18 +281,21 @@ def get_version() -> LooseVersion:
278281
if proc.stderr:
279282
if proc.stderr[0] == "tmux: unknown option -- V":
280283
if sys.platform.startswith("openbsd"): # openbsd has no tmux -V
281-
return LooseVersion("%s-openbsd" % TMUX_MAX_VERSION)
284+
return LooseVersion(f"{TMUX_MAX_VERSION}-openbsd")
285+
msg = (
286+
f"libtmux supports tmux {TMUX_MIN_VERSION} and greater. This system"
287+
" is running tmux 1.3 or earlier."
288+
)
282289
raise exc.LibTmuxException(
283-
"libtmux supports tmux %s and greater. This system"
284-
" is running tmux 1.3 or earlier." % TMUX_MIN_VERSION,
290+
msg,
285291
)
286292
raise exc.VersionTooLow(proc.stderr)
287293

288294
version = proc.stdout[0].split("tmux ")[1]
289295

290296
# Allow latest tmux HEAD
291297
if version == "master":
292-
return LooseVersion("%s-master" % TMUX_MAX_VERSION)
298+
return LooseVersion(f"{TMUX_MAX_VERSION}-master")
293299

294300
version = re.sub(r"[a-z-]", "", version)
295301

src/libtmux/neo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def fetch_objs(
211211
if list_extra_args is not None and isinstance(list_extra_args, t.Iterable):
212212
tmux_cmds.extend(list(list_extra_args))
213213

214-
tmux_cmds.append("-F%s" % "".join(tmux_formats))
214+
tmux_cmds.append("-F{}".format("".join(tmux_formats)))
215215

216216
proc = tmux_cmd(*tmux_cmds) # output
217217

src/libtmux/pane.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def split(
618618
if zoom:
619619
tmux_args += ("-Z",)
620620

621-
tmux_args += ("-P", "-F%s" % "".join(tmux_formats)) # output
621+
tmux_args += ("-P", "-F{}".format("".join(tmux_formats))) # output
622622

623623
if start_directory is not None:
624624
# as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c.

src/libtmux/pytest_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def server(
136136
137137
>>> result.assert_outcomes(passed=1)
138138
"""
139-
server = Server(socket_name="libtmux_test%s" % next(namer))
139+
server = Server(socket_name=f"libtmux_test{next(namer)}")
140140

141141
def fin() -> None:
142142
server.kill()

src/libtmux/server.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,11 @@ def new_session(
462462
if self.has_session(session_name):
463463
if kill_session:
464464
self.cmd("kill-session", target=session_name)
465-
logger.info("session %s exists. killed it." % session_name)
465+
logger.info(f"session {session_name} exists. killed it.")
466466
else:
467+
msg = f"Session named {session_name} exists"
467468
raise exc.TmuxSessionExists(
468-
"Session named %s exists" % session_name,
469+
msg,
469470
)
470471

471472
logger.debug(f"creating session {session_name}")

src/libtmux/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def kill_window(self, target_window: t.Optional[str] = None) -> None:
705705
if isinstance(target_window, int):
706706
target = "%s:%d" % (self.window_name, target_window)
707707
else:
708-
target = "%s" % target_window
708+
target = f"{target_window}"
709709

710710
proc = self.cmd("kill-window", target=target)
711711

tests/legacy_api/test_common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
4444
assert has_gte_version(TMUX_MIN_VERSION)
4545
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
4646
assert (
47-
get_version() == "%s-master" % TMUX_MAX_VERSION
47+
get_version() == f"{TMUX_MAX_VERSION}-master"
4848
), "Is the latest supported version with -master appended"
4949

5050

@@ -82,7 +82,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
8282
assert has_gte_version(TMUX_MIN_VERSION)
8383
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
8484
assert (
85-
get_version() == "%s-openbsd" % TMUX_MAX_VERSION
85+
get_version() == f"{TMUX_MAX_VERSION}-openbsd"
8686
), "Is the latest supported version with -openbsd appended"
8787

8888

tests/test_common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
4444
assert has_gte_version(TMUX_MIN_VERSION)
4545
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
4646
assert (
47-
get_version() == "%s-master" % TMUX_MAX_VERSION
47+
get_version() == f"{TMUX_MAX_VERSION}-master"
4848
), "Is the latest supported version with -master appended"
4949

5050

@@ -82,7 +82,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
8282
assert has_gte_version(TMUX_MIN_VERSION)
8383
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
8484
assert (
85-
get_version() == "%s-openbsd" % TMUX_MAX_VERSION
85+
get_version() == f"{TMUX_MAX_VERSION}-openbsd"
8686
), "Is the latest supported version with -openbsd appended"
8787

8888

0 commit comments

Comments
 (0)