Skip to content

Commit 83daaaf

Browse files
authored
Bump dev dependencies, including ruff 0.4.2, f-string tweaks (#931)
2 parents 296276d + 005fe7c commit 83daaaf

File tree

15 files changed

+202
-189
lines changed

15 files changed

+202
-189
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
1919

2020
<!-- Maintainers, insert changes / features for the next release here -->
2121

22+
### Development
23+
24+
- Code quality: Use f-strings in more places (#931)
25+
26+
via [ruff 0.4.2](https://github.com/astral-sh/ruff/blob/v0.4.2/CHANGELOG.md).
27+
2228
## tmuxp 1.47.0 (2024-04-21)
2329

2430
_Maintenance only, no bug fixes or new features_

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def session_params(session_params: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
9393
@pytest.fixture()
9494
def socket_name(request: pytest.FixtureRequest) -> str:
9595
"""Random socket name for tmuxp."""
96-
return "tmuxp_test%s" % next(namer)
96+
return f"tmuxp_test{next(namer)}"
9797

9898

9999
@pytest.fixture(autouse=True)

docs/_ext/aafig.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def render_aafig_images(app: "Sphinx", doctree: nodes.Node) -> None:
126126
options["format"] = format_map[_format]
127127
else:
128128
logger.warning(
129-
'unsupported builder format "%s", please '
129+
f'unsupported builder format "{_format}", please '
130130
"add a custom entry in aafig_format config "
131-
"option for this builder" % _format,
131+
"option for this builder",
132132
)
133133
img.replace_self(nodes.literal_block(text, text))
134134
continue
@@ -176,14 +176,14 @@ def render_aafigure(
176176
# Non-HTML
177177
if app.builder.format != "latex":
178178
logger.warning(
179-
"aafig: the builder format %s is not officially "
179+
f"aafig: the builder format {app.builder.format} is not officially "
180180
"supported, aafigure images could not work. "
181181
"Please report problems and working builder to "
182-
"avoid this warning in the future" % app.builder.format,
182+
"avoid this warning in the future",
183183
)
184184
relfn = fname
185185
outfn = path.join(app.builder.outdir, fname)
186-
metadata_fname = "%s.aafig" % outfn
186+
metadata_fname = f"{outfn}.aafig"
187187

188188
try:
189189
if path.isfile(outfn):

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
project = about["__title__"]
6161
project_copyright = about["__copyright__"]
6262

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

6666
exclude_patterns = ["_build"]
6767

poetry.lock

Lines changed: 118 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tmuxp/cli/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def command_convert(
8888
if (
8989
not answer_yes
9090
and prompt_yes_no(f"Convert to <{workspace_file}> to {to_filetype}?")
91-
and prompt_yes_no("Save workspace to %s?" % newfile)
91+
and prompt_yes_no(f"Save workspace to {newfile}?")
9292
):
9393
answer_yes = True
9494

src/tmuxp/cli/debug_info.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def command_debug_info(
3333

3434
def prepend_tab(strings: t.List[str]) -> t.List[str]:
3535
"""Prepend tab to strings in list."""
36-
return ["\t%s" % x for x in strings]
36+
return [f"\t{x}" for x in strings]
3737

3838
def output_break() -> str:
3939
"""Generate output break."""
@@ -52,33 +52,37 @@ def format_tmux_resp(std_resp: tmux_cmd) -> str:
5252

5353
output = [
5454
output_break(),
55-
"environment:\n%s"
56-
% "\n".join(
57-
prepend_tab(
58-
[
59-
"dist: %s" % platform.platform(),
60-
"arch: %s" % platform.machine(),
61-
"uname: %s" % "; ".join(platform.uname()[:3]),
62-
"version: %s" % platform.version(),
63-
],
64-
),
55+
"environment:\n{}".format(
56+
"\n".join(
57+
prepend_tab(
58+
[
59+
f"dist: {platform.platform()}",
60+
f"arch: {platform.machine()}",
61+
"uname: {}".format("; ".join(platform.uname()[:3])),
62+
f"version: {platform.version()}",
63+
],
64+
),
65+
)
6566
),
6667
output_break(),
67-
"python version: %s" % " ".join(sys.version.split("\n")),
68-
"system PATH: %s" % os.environ["PATH"],
69-
"tmux version: %s" % get_version(),
70-
"libtmux version: %s" % libtmux_version,
71-
"tmuxp version: %s" % __version__,
72-
"tmux path: %s" % shutil.which("tmux"),
73-
"tmuxp path: %s" % tmuxp_path,
74-
"shell: %s" % os.environ["SHELL"],
68+
"python version: {}".format(" ".join(sys.version.split("\n"))),
69+
"system PATH: {}".format(os.environ["PATH"]),
70+
f"tmux version: {get_version()}",
71+
f"libtmux version: {libtmux_version}",
72+
f"tmuxp version: {__version__}",
73+
"tmux path: {}".format(shutil.which("tmux")),
74+
f"tmuxp path: {tmuxp_path}",
75+
"shell: {}".format(os.environ["SHELL"]),
7576
output_break(),
76-
"tmux sessions:\n%s" % format_tmux_resp(tmux_cmd("list-sessions")),
77-
"tmux windows:\n%s" % format_tmux_resp(tmux_cmd("list-windows")),
78-
"tmux panes:\n%s" % format_tmux_resp(tmux_cmd("list-panes")),
79-
"tmux global options:\n%s" % format_tmux_resp(tmux_cmd("show-options", "-g")),
80-
"tmux window options:\n%s"
81-
% format_tmux_resp(tmux_cmd("show-window-options", "-g")),
77+
"tmux sessions:\n{}".format(format_tmux_resp(tmux_cmd("list-sessions"))),
78+
"tmux windows:\n{}".format(format_tmux_resp(tmux_cmd("list-windows"))),
79+
"tmux panes:\n{}".format(format_tmux_resp(tmux_cmd("list-panes"))),
80+
"tmux global options:\n{}".format(
81+
format_tmux_resp(tmux_cmd("show-options", "-g"))
82+
),
83+
"tmux window options:\n{}".format(
84+
format_tmux_resp(tmux_cmd("show-window-options", "-g"))
85+
),
8286
]
8387

8488
tmuxp_echo("\n".join(output))

src/tmuxp/cli/freeze.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ def command_freeze(
154154
),
155155
)
156156
dest_prompt = prompt(
157-
"Save to: %s" % save_to,
157+
f"Save to: {save_to}",
158158
default=save_to,
159159
)
160160
if not args.force and os.path.exists(dest_prompt):
161-
print("%s exists. Pick a new filename." % dest_prompt)
161+
print(f"{dest_prompt} exists. Pick a new filename.")
162162
continue
163163

164164
dest = dest_prompt
@@ -185,8 +185,9 @@ def extract_workspace_format(
185185
workspace_format = extract_workspace_format(dest)
186186
if not is_valid_ext(workspace_format):
187187
_workspace_format = prompt_choices(
188-
"Couldn't ascertain one of [%s] from file name. Convert to"
189-
% ", ".join(valid_workspace_formats),
188+
"Couldn't ascertain one of [{}] from file name. Convert to".format(
189+
", ".join(valid_workspace_formats)
190+
),
190191
choices=t.cast(t.List[str], valid_workspace_formats),
191192
default="yaml",
192193
)
@@ -203,12 +204,12 @@ def extract_workspace_format(
203204
elif workspace_format == "json":
204205
workspace = configparser.dump(fmt="json", indent=2)
205206

206-
if args.answer_yes or prompt_yes_no("Save to %s?" % dest):
207+
if args.answer_yes or prompt_yes_no(f"Save to {dest}?"):
207208
destdir = os.path.dirname(dest)
208209
if not os.path.isdir(destdir):
209210
os.makedirs(destdir)
210211
with open(dest, "w", encoding=locale.getpreferredencoding(False)) as buf:
211212
buf.write(workspace)
212213

213214
if not args.quiet:
214-
print("Saved to %s." % dest)
215+
print(f"Saved to {dest}.")

src/tmuxp/cli/import_config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def get_teamocil_dir() -> pathlib.Path:
5252
def _resolve_path_no_overwrite(workspace_file: str) -> str:
5353
path = pathlib.Path(workspace_file).resolve()
5454
if path.exists():
55-
raise ValueError("%s exists. Pick a new filename." % path)
55+
msg = f"{path} exists. Pick a new filename."
56+
raise ValueError(msg)
5657
return str(path)
5758

5859

@@ -165,18 +166,18 @@ def import_config(
165166
dest = None
166167
while not dest:
167168
dest_path = prompt(
168-
"Save to [%s]" % os.getcwd(),
169+
f"Save to [{os.getcwd()}]",
169170
value_proc=_resolve_path_no_overwrite,
170171
)
171172

172173
# dest = dest_prompt
173-
if prompt_yes_no("Save to %s?" % dest_path):
174+
if prompt_yes_no(f"Save to {dest_path}?"):
174175
dest = dest_path
175176

176177
with open(dest, "w", encoding=locale.getpreferredencoding(False)) as buf:
177178
buf.write(new_config)
178179

179-
tmuxp_echo("Saved to %s." % dest)
180+
tmuxp_echo(f"Saved to {dest}.")
180181
else:
181182
tmuxp_echo(
182183
"tmuxp has examples in JSON and YAML format at "

src/tmuxp/cli/load.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def load_workspace(
333333
server=t,
334334
)
335335
except exc.EmptyWorkspaceException:
336-
tmuxp_echo("%s is empty or parsed no workspace data" % workspace_file)
336+
tmuxp_echo(f"{workspace_file} is empty or parsed no workspace data")
337337
return None
338338

339339
session_name = expanded_workspace["session_name"]
@@ -343,7 +343,9 @@ def load_workspace(
343343
if not detached and (
344344
answer_yes
345345
or prompt_yes_no(
346-
"%s is already running. Attach?" % style(session_name, fg="green"),
346+
"{} is already running. Attach?".format(
347+
style(session_name, fg="green")
348+
),
347349
default=True,
348350
)
349351
):

0 commit comments

Comments
 (0)