Skip to content
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

Apply ruff/pyupgrade (UP) and ruff/refurb (FURB) rules #1047

Merged
merged 2 commits into from
May 11, 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
2 changes: 1 addition & 1 deletion src/setuptools_scm/_run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def has_command(
else:
res = not p.returncode
if not res and warn:
warnings.warn("%r was not found" % name, category=RuntimeWarning)
warnings.warn(f"{name!r} was not found", category=RuntimeWarning)
return res


Expand Down
4 changes: 2 additions & 2 deletions src/setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dataclasses
import logging
import operator
import os
import re
import shlex
Expand Down Expand Up @@ -144,8 +145,7 @@ def fetch_shallow(self) -> None:
run_git(["fetch", "--unshallow"], self.path, check=True, timeout=240)

def node(self) -> str | None:
def _unsafe_short_node(node: str) -> str:
RonnyPfannschmidt marked this conversation as resolved.
Show resolved Hide resolved
return node[:7]
_unsafe_short_node = operator.itemgetter(slice(7))

return run_git(
["rev-parse", "--verify", "--quiet", "HEAD"], self.path
Expand Down
2 changes: 1 addition & 1 deletion src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def meta(
) -> ScmVersion:
parsed_version = _parse_tag(tag, preformatted, config)
log.info("version %s -> %s", tag, parsed_version)
assert parsed_version is not None, "Can't parse version %s" % tag
assert parsed_version is not None, f"Can't parse version {tag}"
return ScmVersion(
parsed_version,
distance=distance,
Expand Down
2 changes: 1 addition & 1 deletion testing/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_git_dirty_notag(
def test_git_worktree_support(wd: WorkDir, tmp_path: Path) -> None:
wd.commit_testfile()
worktree = tmp_path / "work_tree"
wd("git worktree add -b work-tree %s" % worktree)
wd(f"git worktree add -b work-tree {worktree}")

res = run([sys.executable, "-m", "setuptools_scm", "ls"], cwd=worktree)
assert "test.txt" in res.stdout
Expand Down
4 changes: 2 additions & 2 deletions testing/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ def __init__(self, tag_str: str) -> None:
self.tag = tag_str

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

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

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