Skip to content

Commit df472e7

Browse files
committed
use ruff as formatter
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent b471c5c commit df472e7

18 files changed

Lines changed: 118 additions & 183 deletions

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,6 @@ jobs:
108108
steps:
109109
- name: Checkout code
110110
uses: actions/checkout@v4
111-
- uses: psf/black@stable
111+
- uses: astral-sh/ruff-action@v3
112+
with:
113+
args: "format --check --diff"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ clean:
1515

1616
.PHONY: format
1717
format:
18-
$(PYTHON) -m black .
18+
$(PYTHON) -m ruff format

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ exclude = [
8989
"doc/api/", "doc/generated/", "doc/_build/",
9090
]
9191

92+
[tool.ruff]
93+
line-length = 100
94+
target-version = "py311"
95+
9296
[tool.black]
9397
line-length = 100
9498

src/pkgcheck/addons/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def update_cache(self, force=False):
646646
# skip cache usage when not running on the default branch
647647
if branch != default_branch:
648648
logger.debug(
649-
"skipping %s git repo cache update on " "non-default branch %r",
649+
"skipping %s git repo cache update on non-default branch %r",
650650
repo,
651651
branch,
652652
)

src/pkgcheck/checks/acct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, kind, identifier, **kwargs):
5555

5656
@property
5757
def desc(self):
58-
return f"{self.kind} id {self.identifier} outside permitted " f"static allocation range"
58+
return f"{self.kind} id {self.identifier} outside permitted static allocation range"
5959

6060

6161
class AcctCheck(GentooRepoCheck, RepoCheck):

src/pkgcheck/checks/codingstyle.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,7 @@ def __init__(self, cmd, **kwargs):
356356

357357
@property
358358
def desc(self):
359-
return (
360-
f"deprecated insinto usage (use {self.cmd} instead), "
361-
f"line {self.lineno}: {self.line}"
362-
)
359+
return f"deprecated insinto usage (use {self.cmd} instead), line {self.lineno}: {self.line}"
363360

364361

365362
class InsintoCheck(Check):

src/pkgcheck/checks/metadata.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ def __init__(self, license_group, license, restrictions, **kwargs):
7777
@property
7878
def desc(self):
7979
restrictions = " ".join(self.restrictions)
80-
return (
81-
f"{self.license_group} license {self.license!r} " f'requires RESTRICT="{restrictions}"'
82-
)
80+
return f'{self.license_group} license {self.license!r} requires RESTRICT="{restrictions}"'
8381

8482

8583
class UnnecessaryLicense(results.VersionResult, results.Warning):
@@ -374,8 +372,7 @@ def desc(self):
374372
num_profiles = ""
375373
# collapsed version
376374
return (
377-
f"profile: {self.profile!r}{num_profiles} "
378-
f"failed REQUIRED_USE: {self.required_use}"
375+
f"profile: {self.profile!r}{num_profiles} failed REQUIRED_USE: {self.required_use}"
379376
)
380377
return (
381378
f"keyword: {self.keyword}, profile: {self.profile!r}, "
@@ -707,7 +704,7 @@ def __init__(self, dep, dep_slots, **kwargs):
707704

708705
@property
709706
def desc(self):
710-
return f"{self.dep!r} matches more than one slot: " f"[ {', '.join(self.dep_slots)} ]"
707+
return f"{self.dep!r} matches more than one slot: [ {', '.join(self.dep_slots)} ]"
711708

712709

713710
class MissingSlotDepCheck(Check):
@@ -782,8 +779,7 @@ def desc(self):
782779
s = pluralism(self.pkgs)
783780
pkgs = ", ".join(self.pkgs)
784781
return (
785-
f'{self.attr}="{self.atom}": USE flag {self.flag!r} missing from '
786-
f"package{s}: [ {pkgs} ]"
782+
f'{self.attr}="{self.atom}": USE flag {self.flag!r} missing from package{s}: [ {pkgs} ]'
787783
)
788784

789785

@@ -1009,8 +1005,7 @@ def __init__(self, attr, atom, age, **kwargs):
10091005
@property
10101006
def desc(self):
10111007
return (
1012-
f'outdated blocker {self.attr}="{self.atom}": '
1013-
f"last match removed {self.age} years ago"
1008+
f'outdated blocker {self.attr}="{self.atom}": last match removed {self.age} years ago'
10141009
)
10151010

10161011

@@ -1030,7 +1025,7 @@ def __init__(self, attr, atom, **kwargs):
10301025

10311026
@property
10321027
def desc(self):
1033-
return f'nonexistent blocker {self.attr}="{self.atom}": ' "no matches in repo history"
1028+
return f'nonexistent blocker {self.attr}="{self.atom}": no matches in repo history'
10341029

10351030

10361031
class OutdatedBlockersCheck(Check):
@@ -1564,8 +1559,7 @@ def feed(self, pkg):
15641559
yield BadHomepage(f"HOMEPAGE={homepage!r} lacks protocol", pkg=pkg)
15651560
elif homepage[:i] not in SrcUriCheck.valid_protos:
15661561
yield BadHomepage(
1567-
f"HOMEPAGE={homepage!r} uses unsupported "
1568-
f"protocol {homepage[:i]!r}",
1562+
f"HOMEPAGE={homepage!r} uses unsupported protocol {homepage[:i]!r}",
15691563
pkg=pkg,
15701564
)
15711565

src/pkgcheck/checks/profiles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ def _deprecated(self, filename, node, vals):
284284
addons.profiles.ProfileNode(pjoin(self.profiles_dir, replacement))
285285
except profiles_mod.ProfileError:
286286
yield ProfileError(
287-
f"nonexistent replacement {replacement!r} "
288-
f"for deprecated profile: {node.name!r}"
287+
f"nonexistent replacement {replacement!r} for deprecated profile: {node.name!r}"
289288
)
290289

291290
# non-spec files

src/pkgcheck/checks/python.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,7 @@ def __init__(self, filename, uri, **kwargs):
727727

728728
@property
729729
def desc(self):
730-
return (
731-
f"GitHub archive {self.filename!r} ({self.uri!r}) is not " "using '.gh.tar.gz' suffix"
732-
)
730+
return f"GitHub archive {self.filename!r} ({self.uri!r}) is not using '.gh.tar.gz' suffix"
733731

734732

735733
class PythonInlinePyPIURI(results.VersionResult, results.Warning):

src/pkgcheck/checks/visibility.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class FakeConfigurable:
15-
"Package wrapper binding profile data." ""
15+
"Package wrapper binding profile data."
1616

1717
configurable = True
1818
__slots__ = ("use", "iuse", "_forced_use", "_masked_use", "_pkg_use", "_raw_pkg", "_profile")
@@ -114,8 +114,7 @@ def desc(self):
114114
num_profiles = ""
115115

116116
return (
117-
f'VCS version visible for KEYWORDS="{self.arch}", '
118-
f"profile {self.profile}{num_profiles}"
117+
f'VCS version visible for KEYWORDS="{self.arch}", profile {self.profile}{num_profiles}'
119118
)
120119

121120

0 commit comments

Comments
 (0)