Skip to content

Commit a4f3d38

Browse files
Merge pull request #1047 from DimitriPapadopoulos/UP_FURB
Apply ruff/pyupgrade (UP) and ruff/refurb (FURB) rules
2 parents 67d154a + 6d46996 commit a4f3d38

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/setuptools_scm/_run_cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def has_command(
201201
else:
202202
res = not p.returncode
203203
if not res and warn:
204-
warnings.warn("%r was not found" % name, category=RuntimeWarning)
204+
warnings.warn(f"{name!r} was not found", category=RuntimeWarning)
205205
return res
206206

207207

src/setuptools_scm/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dataclasses
44
import logging
5+
import operator
56
import os
67
import re
78
import shlex
@@ -144,8 +145,7 @@ def fetch_shallow(self) -> None:
144145
run_git(["fetch", "--unshallow"], self.path, check=True, timeout=240)
145146

146147
def node(self) -> str | None:
147-
def _unsafe_short_node(node: str) -> str:
148-
return node[:7]
148+
_unsafe_short_node = operator.itemgetter(slice(7))
149149

150150
return run_git(
151151
["rev-parse", "--verify", "--quiet", "HEAD"], self.path

src/setuptools_scm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def meta(
216216
) -> ScmVersion:
217217
parsed_version = _parse_tag(tag, preformatted, config)
218218
log.info("version %s -> %s", tag, parsed_version)
219-
assert parsed_version is not None, "Can't parse version %s" % tag
219+
assert parsed_version is not None, f"Can't parse version {tag}"
220220
return ScmVersion(
221221
parsed_version,
222222
distance=distance,

testing/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def test_git_dirty_notag(
299299
def test_git_worktree_support(wd: WorkDir, tmp_path: Path) -> None:
300300
wd.commit_testfile()
301301
worktree = tmp_path / "work_tree"
302-
wd("git worktree add -b work-tree %s" % worktree)
302+
wd(f"git worktree add -b work-tree {worktree}")
303303

304304
res = run([sys.executable, "-m", "setuptools_scm", "ls"], cwd=worktree)
305305
assert "test.txt" in res.stdout

testing/test_version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ def __init__(self, tag_str: str) -> None:
432432
self.tag = tag_str
433433

434434
def __str__(self) -> str:
435-
return "Custom %s" % self.tag
435+
return f"Custom {self.tag}"
436436

437437
def __repr__(self) -> str:
438-
return "MyVersion<Custom%s>" % self.tag
438+
return f"MyVersion<Custom{self.tag}>"
439439

440440
config = Configuration(version_cls=MyVersion) # type: ignore[arg-type]
441441
scm_version = meta("1.0.0-foo", config=config)

0 commit comments

Comments
 (0)