Skip to content

Commit 14ba154

Browse files
committed
use ruff as formatter
Signed-off-by: Arthur Zamarin <[email protected]>
1 parent ff924c6 commit 14ba154

File tree

8 files changed

+19
-11
lines changed

8 files changed

+19
-11
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ jobs:
8989
steps:
9090
- name: Checkout code
9191
uses: actions/checkout@v4
92-
- uses: psf/black@stable
92+
- uses: astral-sh/ruff-action@v3
93+
with:
94+
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
@@ -68,6 +68,10 @@ exclude = [
6868
"doc/api/", "doc/generated/", "doc/_build/",
6969
]
7070

71+
[tool.ruff]
72+
line-length = 100
73+
target-version = "py311"
74+
7175
[tool.black]
7276
line-length = 100
7377

src/pkgdev/mangle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def keywords_sort_key(kw):
8282
new_kw = " ".join(kw)
8383
if not mo.group("quote"):
8484
new_kw = f'"{new_kw}"'
85-
lines[i] = f'{mo.group("pre")}{new_kw}{mo.group("post")}'
85+
lines[i] = f"{mo.group('pre')}{new_kw}{mo.group('post')}"
8686
break
8787
return change.update("\n".join(lines) + "\n")
8888

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ def build_full_graph(self):
497497
if pkg_has_stable and not keywords: # package already done
498498
self.out.write(f"Nothing to stable for {pkg.unversioned_atom}")
499499
continue
500-
assert (
501-
keywords
502-
), f"no keywords for {pkg.versioned_atom}, currently unsupported by tool: https://github.com/pkgcore/pkgdev/issues/123"
500+
assert keywords, (
501+
f"no keywords for {pkg.versioned_atom}, currently unsupported by tool: https://github.com/pkgcore/pkgdev/issues/123"
502+
)
503503
self.nodes.add(new_node := GraphNode(((pkg, keywords),)))
504504
vertices[pkg] = new_node
505505
if reason:

src/pkgdev/scripts/pkgdev_showkw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Output table using specified tabular format (defaults to compressed,
3434
custom format).
3535
36-
Available formats: {', '.join(tabulate_formats)}
36+
Available formats: {", ".join(tabulate_formats)}
3737
""",
3838
)
3939
output_opts.add_argument(

src/pkgdev/scripts/pkgdev_tatt.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,10 @@ def _build_job(namespace, pkg, is_test: bool):
309309
)
310310
for solution in solutions:
311311
use_flags, use_expand = _groupby_use_expand(solution, use_expand_prefixes, enabled, iuse)
312-
yield " ".join(use_flags) + " " + " ".join(
313-
f'{var.upper()}: {" ".join(vals)}' for var, vals in use_expand.items()
312+
yield (
313+
" ".join(use_flags)
314+
+ " "
315+
+ " ".join(f"{var.upper()}: {' '.join(vals)}" for var, vals in use_expand.items())
314316
)
315317

316318

@@ -335,7 +337,7 @@ def _create_config_files(pkgs, job_name, is_keywording):
335337
with (res := portage_accept_keywords / f"pkgdev_tatt_{job_name}.keywords").open("w") as f:
336338
f.write(f"# Job created by pkgdev tatt for {job_name!r}\n")
337339
for pkg in pkgs:
338-
f.write(f'{pkg.versioned_atom} {"**" if is_keywording else ""}\n')
340+
f.write(f"{pkg.versioned_atom} {'**' if is_keywording else ''}\n")
339341
yield str(res)
340342

341343
_create_config_dir(portage_env)

tests/scripts/test_pkgdev_bugs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def mk_pkg(repo, cpvstr, maintainers, **kwargs):
2626
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
2727
<pkgmetadata>
2828
<maintainer type="person">
29-
{' '.join(f'<email>{maintainer}@gentoo.org</email>' for maintainer in maintainers)}
29+
{" ".join(f"<email>{maintainer}@gentoo.org</email>" for maintainer in maintainers)}
3030
</maintainer>
3131
</pkgmetadata>
3232
"""

0 commit comments

Comments
 (0)