Skip to content

Bump dev dependencies, including ruff 0.4.2, f-string tweaks #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ $ pip install --user --upgrade --pre libtmux

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

### Development

- Code quality: Use f-strings in more places (#540)

via [ruff 0.4.2](https://github.com/astral-sh/ruff/blob/v0.4.2/CHANGELOG.md).

## libtmux 0.37.0 (04-21-2024)

_Maintenance only, no bug fixes or new features_
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
project = about["__title__"]
project_copyright = about["__copyright__"]

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

exclude_patterns = ["_build"]

Expand Down
230 changes: 115 additions & 115 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions src/libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def set_environment(self, name: str, value: str) -> None:
if isinstance(cmd.stderr, list) and len(cmd.stderr) == 1
else cmd.stderr
)
raise ValueError("tmux set-environment stderr: %s" % cmd.stderr)
msg = f"tmux set-environment stderr: {cmd.stderr}"
raise ValueError(msg)

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

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

def show_environment(self) -> Dict[str, Union[bool, str]]:
"""Show environment ``$ tmux show-environment -t [session]``.
Expand Down Expand Up @@ -278,18 +281,21 @@ def get_version() -> LooseVersion:
if proc.stderr:
if proc.stderr[0] == "tmux: unknown option -- V":
if sys.platform.startswith("openbsd"): # openbsd has no tmux -V
return LooseVersion("%s-openbsd" % TMUX_MAX_VERSION)
return LooseVersion(f"{TMUX_MAX_VERSION}-openbsd")
msg = (
f"libtmux supports tmux {TMUX_MIN_VERSION} and greater. This system"
" is running tmux 1.3 or earlier."
)
raise exc.LibTmuxException(
"libtmux supports tmux %s and greater. This system"
" is running tmux 1.3 or earlier." % TMUX_MIN_VERSION,
msg,
)
raise exc.VersionTooLow(proc.stderr)

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

# Allow latest tmux HEAD
if version == "master":
return LooseVersion("%s-master" % TMUX_MAX_VERSION)
return LooseVersion(f"{TMUX_MAX_VERSION}-master")

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

Expand Down
2 changes: 1 addition & 1 deletion src/libtmux/neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def fetch_objs(
if list_extra_args is not None and isinstance(list_extra_args, t.Iterable):
tmux_cmds.extend(list(list_extra_args))

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

proc = tmux_cmd(*tmux_cmds) # output

Expand Down
2 changes: 1 addition & 1 deletion src/libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def split(
if zoom:
tmux_args += ("-Z",)

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

if start_directory is not None:
# as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c.
Expand Down
2 changes: 1 addition & 1 deletion src/libtmux/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def server(

>>> result.assert_outcomes(passed=1)
"""
server = Server(socket_name="libtmux_test%s" % next(namer))
server = Server(socket_name=f"libtmux_test{next(namer)}")

def fin() -> None:
server.kill()
Expand Down
5 changes: 3 additions & 2 deletions src/libtmux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,11 @@ def new_session(
if self.has_session(session_name):
if kill_session:
self.cmd("kill-session", target=session_name)
logger.info("session %s exists. killed it." % session_name)
logger.info(f"session {session_name} exists. killed it.")
else:
msg = f"Session named {session_name} exists"
raise exc.TmuxSessionExists(
"Session named %s exists" % session_name,
msg,
)

logger.debug(f"creating session {session_name}")
Expand Down
2 changes: 1 addition & 1 deletion src/libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def kill_window(self, target_window: t.Optional[str] = None) -> None:
if isinstance(target_window, int):
target = "%s:%d" % (self.window_name, target_window)
else:
target = "%s" % target_window
target = f"{target_window}"

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

Expand Down
4 changes: 2 additions & 2 deletions tests/legacy_api/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
assert has_gte_version(TMUX_MIN_VERSION)
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
assert (
get_version() == "%s-master" % TMUX_MAX_VERSION
get_version() == f"{TMUX_MAX_VERSION}-master"
), "Is the latest supported version with -master appended"


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


Expand Down
4 changes: 2 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
assert has_gte_version(TMUX_MIN_VERSION)
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
assert (
get_version() == "%s-master" % TMUX_MAX_VERSION
get_version() == f"{TMUX_MAX_VERSION}-master"
), "Is the latest supported version with -master appended"


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


Expand Down