commit:     676196898015c7bdd315f08364d6766b246363da
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat May 31 17:47:16 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat May 31 17:47:16 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=67619689

use ruff as formatter

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .github/workflows/test.yml           |  4 +++-
 Makefile                             |  2 +-
 doc/conf.py                          |  4 +---
 src/snakeoil/compression/__init__.py |  3 +--
 src/snakeoil/constraints.py          |  6 +++---
 src/snakeoil/demandload.py           |  2 +-
 src/snakeoil/formatters.py           |  3 +--
 src/snakeoil/test/__init__.py        |  6 +++---
 tests/test_bash.py                   | 36 +++++++++---------------------------
 tests/test_formatters.py             | 12 ++++++------
 tests/test_obj.py                    |  7 ++-----
 11 files changed, 31 insertions(+), 54 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 52ccacf..9547799 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -62,4 +62,6 @@ jobs:
     steps:
     - name: Checkout code
       uses: actions/checkout@v4
-    - uses: psf/black@stable
+    - uses: astral-sh/ruff-action@v3
+      with:
+        args: "format --check --diff"

diff --git a/Makefile b/Makefile
index b5cadc8..a342679 100644
--- a/Makefile
+++ b/Makefile
@@ -16,4 +16,4 @@ clean:
 
 .PHONY: format
 format:
-       $(PYTHON) -m black .
+       $(PYTHON) -m ruff format

diff --git a/doc/conf.py b/doc/conf.py
index c014b53..a8a9a49 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -254,9 +254,7 @@ autosummary_generate = False
 rst_epilog = """
 .. |homepage| replace:: https://github.com/pkgcore/snakeoil
 .. |release_url| replace:: https://github.com/pkgcore/snakeoil/releases
-""" % {
-    "release": release
-}
+"""
 
 extlinks = {
     "git_tag": ("https://github.com/pkgcore/snakeoil/releases/tag/%s";, "git 
log "),

diff --git a/src/snakeoil/compression/__init__.py 
b/src/snakeoil/compression/__init__.py
index 96dd75f..08e6828 100644
--- a/src/snakeoil/compression/__init__.py
+++ b/src/snakeoil/compression/__init__.py
@@ -171,8 +171,7 @@ class _Tar(_Archive, ArComp):
             else:
                 choices = ", ".join(next(zip(*self.compress_binary)))
                 raise ArCompError(
-                    "no compression binary found from the "
-                    f"following choices: {choices}"
+                    f"no compression binary found from the following choices: 
{choices}"
                 )
         return cmd
 

diff --git a/src/snakeoil/constraints.py b/src/snakeoil/constraints.py
index 5fe46ec..a744cce 100644
--- a/src/snakeoil/constraints.py
+++ b/src/snakeoil/constraints.py
@@ -98,9 +98,9 @@ class Problem:
             from each domain.
         """
         for variable in variables:
-            assert (
-                variable not in self.variables
-            ), f"variable {variable!r} was already added"
+            assert variable not in self.variables, (
+                f"variable {variable!r} was already added"
+            )
             self.variables[variable] = _Domain(domain)
 
     def add_constraint(self, constraint: Constraint, variables: 
frozenset[str]):

diff --git a/src/snakeoil/demandload.py b/src/snakeoil/demandload.py
index 1fc6b63..b1d80ba 100644
--- a/src/snakeoil/demandload.py
+++ b/src/snakeoil/demandload.py
@@ -200,7 +200,7 @@ class Placeholder:
                     raise ValueError(f"Placeholder for {name!r} was triggered 
twice")
                 elif _noisy_protection():
                     logging.warning(
-                        "Placeholder for %r was triggered multiple times " "in 
file %r",
+                        "Placeholder for %r was triggered multiple times in 
file %r",
                         name,
                         scope.get("__file__", "unknown"),
                     )

diff --git a/src/snakeoil/formatters.py b/src/snakeoil/formatters.py
index 0f65209..505e137 100644
--- a/src/snakeoil/formatters.py
+++ b/src/snakeoil/formatters.py
@@ -211,8 +211,7 @@ class PlainTextFormatter(Formatter):
         if prefixes is not None:
             if first_prefixes is not None or later_prefixes is not None:
                 raise TypeError(
-                    "do not pass first_prefixes or later_prefixes "
-                    "if prefixes is passed"
+                    "do not pass first_prefixes or later_prefixes if prefixes 
is passed"
                 )
             first_prefixes = later_prefixes = prefixes
         prefix = kwargs.get("prefix")

diff --git a/src/snakeoil/test/__init__.py b/src/snakeoil/test/__init__.py
index b93094a..a14466b 100644
--- a/src/snakeoil/test/__init__.py
+++ b/src/snakeoil/test/__init__.py
@@ -72,9 +72,9 @@ def protect_process(functor, name=None):
             )
             stdout, _ = p.communicate()
             ret = p.wait()
-            assert (
-                ret == 0
-            ), f"subprocess run: {args!r}\nnon zero exit: 
{ret}\nstdout:\n{stdout}"
+            assert ret == 0, (
+                f"subprocess run: {args!r}\nnon zero exit: 
{ret}\nstdout:\n{stdout}"
+            )
         finally:
             if wipe:
                 os.environ.pop(_PROTECT_ENV_VAR, None)

diff --git a/tests/test_bash.py b/tests/test_bash.py
index 3d2157b..8c40d8e 100644
--- a/tests/test_bash.py
+++ b/tests/test_bash.py
@@ -13,9 +13,7 @@ from snakeoil.bash import (
 class TestBashCommentStripping:
     def test_iter_read_bash(self):
         output = iter_read_bash(
-            StringIO(
-                "\n" "# hi I am a comment\n" "I am not \n" " asdf # inline 
comment\n"
-            )
+            StringIO("\n# hi I am a comment\nI am not \n asdf # inline 
comment\n")
         )
         assert list(output) == ["I am not", "asdf"]
 
@@ -40,11 +38,7 @@ class TestBashCommentStripping:
         # continuation into inline comment
         output = iter_read_bash(
             StringIO(
-                "\n"
-                "# hi I am a comment\n"
-                "I am \\\n"
-                "not a \\\n"
-                "comment # inline comment\n"
+                "\n# hi I am a comment\nI am \\\nnot a \\\ncomment # inline 
comment\n"
             ),
             allow_line_cont=True,
         )
@@ -52,15 +46,7 @@ class TestBashCommentStripping:
 
         # ends with continuation
         output = iter_read_bash(
-            StringIO(
-                "\n"
-                "# hi I am a comment\n"
-                "I am \\\n"
-                "\\\n"
-                "not a \\\n"
-                "comment\\\n"
-                "\\\n"
-            ),
+            StringIO("\n# hi I am a comment\nI am \\\n\\\nnot a 
\\\ncomment\\\n\\\n"),
             allow_line_cont=True,
         )
         assert list(output) == ["I am not a comment"]
@@ -84,25 +70,23 @@ class TestBashCommentStripping:
         # Line continuations have to end with \<newline> without any backslash
         # before the pattern.
         output = iter_read_bash(
-            StringIO("I am \\ \n" "not a comment"), allow_line_cont=True
+            StringIO("I am \\ \nnot a comment"), allow_line_cont=True
         )
         assert list(output) == ["I am \\", "not a comment"]
         output = iter_read_bash(
-            StringIO("\\\n" "I am \\\\\n" "not a comment"), 
allow_line_cont=True
+            StringIO("\\\nI am \\\\\nnot a comment"), allow_line_cont=True
         )
         assert list(output) == ["I am \\\\", "not a comment"]
 
     def test_read_bash(self):
-        output = read_bash(StringIO("\n" "# hi I am a comment\n" "I am not\n"))
+        output = read_bash(StringIO("\n# hi I am a comment\nI am not\n"))
         assert output == ["I am not"]
 
 
 class TestReadDictConfig:
     def test_read_dict(self):
         bash_dict = read_dict(
-            StringIO(
-                "\n" "# hi I am a comment\n" "foo1=bar\n" 'foo2="bar"\n' 
"foo3='bar\"\n"
-            )
+            StringIO('\n# hi I am a 
comment\nfoo1=bar\nfoo2="bar"\nfoo3=\'bar"\n')
         )
         assert bash_dict == {
             "foo1": "bar",
@@ -140,14 +124,12 @@ class TestReadBashDict:
         self.sourcing_file2 = tmp_path / "sourcing2"
         self.sourcing_file2.write_text(f'source "{self.valid_file}"\n')
         self.advanced_file = tmp_path / "advanced"
-        self.advanced_file.write_text(
-            "one1=1\n" "one_=$one1\n" "two1=2\n" "two_=${two1}\n"
-        )
+        
self.advanced_file.write_text("one1=1\none_=$one1\ntwo1=2\ntwo_=${two1}\n")
         self.env_file = tmp_path / "env"
         self.env_file.write_text("imported=${external}\n")
         self.escaped_file = tmp_path / "escaped"
         self.escaped_file.write_text(
-            "end=bye\n" 'quoteddollar="\\${dollar}"\n' 
'quotedexpansion="\\${${end}}"\n'
+            
'end=bye\nquoteddollar="\\${dollar}"\nquotedexpansion="\\${${end}}"\n'
         )
         self.unclosed_file = tmp_path / "unclosed"
         self.unclosed_file.write_text('foo="bar')

diff --git a/tests/test_formatters.py b/tests/test_formatters.py
index 515511c..b594a5d 100644
--- a/tests/test_formatters.py
+++ b/tests/test_formatters.py
@@ -37,11 +37,11 @@ class TestPlainTextFormatter:
             (("\N{SNOWMAN}",), "foon:?"),
             (
                 (7 * "spork ",),
-                "foon:spork spork\n" "spork spork spork\n" "spork spork ",
+                "foon:spork spork\nspork spork spork\nspork spork ",
             ),
             (
                 7 * ("spork ",),
-                "foon:spork spork \n" "spork spork spork \n" "spork spork ",
+                "foon:spork spork \nspork spork spork \nspork spork ",
             ),
             ((30 * "a"), "foon:" + 15 * "a" + "\n" + 15 * "a"),
             (30 * ("a",), "foon:" + 15 * "a" + "\n" + 15 * "a"),
@@ -57,11 +57,11 @@ class TestPlainTextFormatter:
             (("\N{SNOWMAN}",), "?"),
             (
                 (7 * "spork ",),
-                "spork spork spork\n" "foon:spork spork\n" "foon:spork spork ",
+                "spork spork spork\nfoon:spork spork\nfoon:spork spork ",
             ),
             (
                 7 * ("spork ",),
-                "spork spork spork \n" "foon:spork spork \n" "foon:spork spork 
",
+                "spork spork spork \nfoon:spork spork \nfoon:spork spork ",
             ),
             ((30 * "a"), 20 * "a" + "\n" + "foon:" + 10 * "a"),
             (30 * ("a",), 20 * "a" + "\n" + "foon:" + 10 * "a"),
@@ -127,7 +127,7 @@ class TestPlainTextFormatter:
         for inputs, output in [
             ((3 * ("spork",)), "spork\nspork\nspork\n"),
             (3 * (("spork",),), "spork\nspork\nspork\n"),
-            (((3 * "spork",),), "\n" "foonsporks\n" "foonporksp\n" 
"foonork\n"),
+            (((3 * "spork",),), "\nfoonsporks\nfoonporksp\nfoonork\n"),
             (
                 (
                     ("fo",),
@@ -140,7 +140,7 @@ class TestPlainTextFormatter:
                     ("fo",),
                     (3 * "spork",),
                 ),
-                "fo\n" "\n" "foonsporks\n" "foonporksp\n" "foonork\n",
+                "fo\n\nfoonsporks\nfoonporksp\nfoonork\n",
             ),
         ]:
             stream = BytesIO()

diff --git a/tests/test_obj.py b/tests/test_obj.py
index 78083d8..03a0338 100644
--- a/tests/test_obj.py
+++ b/tests/test_obj.py
@@ -40,11 +40,8 @@ class TestDelayedInstantiation:
             missing.difference_update(obj.base_kls_descriptors)
             missing.difference_update(default_ignores)
             missing.difference_update(ignores)
-            assert (
-                not missing
-            ), "object %r potentially has unsupported special " "attributes: 
%s" % (
-                cls,
-                ", ".join(missing),
+            assert not missing, (
+                f"object {cls!r} potentially has unsupported special 
attributes: {', '.join(missing)}"
             )
 
         assertKls(object)

Reply via email to