Browse Source

Bump ruff to 0.9.1

Jelmer Vernooij 2 months ago
parent
commit
a0edc61140

+ 1 - 1
dulwich/cli.py

@@ -272,7 +272,7 @@ class cmd_clone(Command):
             "--branch",
             dest="branch",
             type=str,
-            help=("Check out branch instead of branch pointed to by remote " "HEAD"),
+            help=("Check out branch instead of branch pointed to by remote HEAD"),
         )
         parser.add_option(
             "--refspec",

+ 2 - 2
dulwich/client.py

@@ -604,11 +604,11 @@ def _handle_upload_pack_head(
         if protocol_version == 2:
             if not find_capability(capabilities, CAPABILITY_FETCH, CAPABILITY_SHALLOW):
                 raise GitProtocolError(
-                    "server does not support shallow capability required for " "depth"
+                    "server does not support shallow capability required for depth"
                 )
         elif CAPABILITY_SHALLOW not in capabilities:
             raise GitProtocolError(
-                "server does not support shallow capability required for " "depth"
+                "server does not support shallow capability required for depth"
             )
         for sha in graph_walker.shallow:
             proto.write_pkt_line(COMMAND_SHALLOW + b" " + sha + b"\n")

+ 1 - 1
dulwich/config.py

@@ -631,7 +631,7 @@ def _find_git_in_win_reg():
             "CurrentVersion\\Uninstall\\Git_is1"
         )
     else:
-        subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" "Uninstall\\Git_is1"
+        subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1"
 
     for key in (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE):  # type: ignore
         with suppress(OSError):

+ 1 - 2
dulwich/index.py

@@ -712,8 +712,7 @@ if sys.platform == "win32":
         def __init__(self, errno, msg, filename) -> None:
             super(PermissionError, self).__init__(
                 errno,
-                "Unable to create symlink; "
-                f"do you have developer mode enabled? {msg}",
+                f"Unable to create symlink; do you have developer mode enabled? {msg}",
                 filename,
             )
 

+ 3 - 3
dulwich/lru_cache.py

@@ -136,14 +136,14 @@ class LRUCache(Generic[K, V]):
             if node.next_key is _null_key:
                 if node is not self._least_recently_used:
                     raise AssertionError(
-                        "only the last node should have" f" no next value: {node}"
+                        f"only the last node should have no next value: {node}"
                     )
                 node_next = None
             else:
                 node_next = self._cache[node.next_key]
                 if node_next.prev is not node:
                     raise AssertionError(
-                        "inconsistency found, node.next.prev" f" != node: {node}"
+                        f"inconsistency found, node.next.prev != node: {node}"
                     )
             if node.prev is None:
                 if node is not self._most_recently_used:
@@ -154,7 +154,7 @@ class LRUCache(Generic[K, V]):
             else:
                 if node.prev.next_key != node.key:
                     raise AssertionError(
-                        "inconsistency found, node.prev.next" f" != node: {node}"
+                        f"inconsistency found, node.prev.next != node: {node}"
                     )
             yield node
             node = node_next

+ 2 - 3
dulwich/objects.py

@@ -892,8 +892,7 @@ class Tag(ShaFile):
     )
     tag_time = serializable_property(
         "tag_time",
-        "The creation timestamp of the tag.  As the number of seconds "
-        "since the epoch",
+        "The creation timestamp of the tag.  As the number of seconds since the epoch",
     )
     tag_timezone = serializable_property(
         "tag_timezone", "The timezone that tag_time is in."
@@ -1644,7 +1643,7 @@ class Commit(ShaFile):
 
     commit_time = serializable_property(
         "commit_time",
-        "The timestamp of the commit. As the number of seconds since the " "epoch.",
+        "The timestamp of the commit. As the number of seconds since the epoch.",
     )
 
     commit_timezone = serializable_property(

+ 3 - 3
dulwich/pack.py

@@ -2485,9 +2485,9 @@ class Pack:
 
     def check_length_and_checksum(self) -> None:
         """Sanity check the length and checksum of the pack index and data."""
-        assert len(self.index) == len(
-            self.data
-        ), f"Length mismatch: {len(self.index)} (index) != {len(self.data)} (data)"
+        assert len(self.index) == len(self.data), (
+            f"Length mismatch: {len(self.index)} (index) != {len(self.data)} (data)"
+        )
         idx_stored_checksum = self.index.get_pack_checksum()
         data_stored_checksum = self.data.get_stored_checksum()
         if idx_stored_checksum != data_stored_checksum:

+ 5 - 6
dulwich/server.py

@@ -257,12 +257,12 @@ class PackHandler(Handler):
                 continue
             if cap not in allowable_caps:
                 raise GitProtocolError(
-                    f"Client asked for capability {cap!r} that " "was not advertised."
+                    f"Client asked for capability {cap!r} that was not advertised."
                 )
         for cap in self.required_capabilities():
             if cap not in caps:
                 raise GitProtocolError(
-                    "Client does not support required " f"capability {cap!r}."
+                    f"Client does not support required capability {cap!r}."
                 )
         self._client_capabilities = set(caps)
         logger.info("Client capabilities: %s", caps)
@@ -270,7 +270,7 @@ class PackHandler(Handler):
     def has_capability(self, cap: bytes) -> bool:
         if self._client_capabilities is None:
             raise GitProtocolError(
-                f"Server attempted to access capability {cap!r} " "before asking client"
+                f"Server attempted to access capability {cap!r} before asking client"
             )
         return cap in self._client_capabilities
 
@@ -1004,8 +1004,7 @@ class ReceivePackHandler(PackHandler):
                 if sha == ZERO_SHA:
                     if CAPABILITY_DELETE_REFS not in self.capabilities():
                         raise GitProtocolError(
-                            "Attempted to delete refs without delete-refs "
-                            "capability."
+                            "Attempted to delete refs without delete-refs capability."
                         )
                     try:
                         self.repo.refs.remove_if_equals(ref, oldsha)
@@ -1195,7 +1194,7 @@ class TCPGitServer(socketserver.TCPServer):
 
     def handle_error(self, request, client_address) -> None:
         logger.exception(
-            "Exception happened during processing of request " "from %s",
+            "Exception happened during processing of request from %s",
             client_address,
         )
 

+ 1 - 1
pyproject.toml

@@ -41,7 +41,7 @@ https = ["urllib3>=1.24.1"]
 pgp = ["gpg"]
 paramiko = ["paramiko"]
 dev = [
-    "ruff==0.8.6",
+    "ruff==0.9.1",
     "mypy==1.14.1"
 ]
 

+ 1 - 1
tests/contrib/test_swift.py

@@ -468,7 +468,7 @@ class TestSwiftConnector(TestCase):
             lambda *args: None,
         ):
             with patch(
-                "dulwich.contrib.swift.SwiftConnector." "get_container_objects",
+                "dulwich.contrib.swift.SwiftConnector.get_container_objects",
                 lambda *args: ({"name": "a"}, {"name": "b"}),
             ):
                 with patch(

+ 3 - 5
tests/test_client.py

@@ -131,7 +131,7 @@ class GitClientTests(TestCase):
         )
 
     def test_archive_ack(self) -> None:
-        self.rin.write(b"0009NACK\n" b"0000")
+        self.rin.write(b"0009NACK\n0000")
         self.rin.seek(0)
         self.client.archive(b"bla", b"HEAD", None, None)
         self.assertEqual(self.rout.getvalue(), b"0011argument HEAD0000")
@@ -1636,8 +1636,7 @@ class PLinkSSHVendorTests(TestCase):
         )
 
         expected_warning = UserWarning(
-            "Invoking PLink with a password exposes the password in the "
-            "process list."
+            "Invoking PLink with a password exposes the password in the process list."
         )
 
         for w in warnings_list:
@@ -1682,8 +1681,7 @@ class PLinkSSHVendorTests(TestCase):
         command = vendor.run_command("host", "git-clone-url", password="12345")
 
         expected_warning = UserWarning(
-            "Invoking PLink with a password exposes the password in the "
-            "process list."
+            "Invoking PLink with a password exposes the password in the process list."
         )
 
         for w in warnings_list:

+ 4 - 4
tests/test_config.py

@@ -144,15 +144,15 @@ class ConfigFileTests(TestCase):
         self.assertRaises(ValueError, self.from_file, b'[core]\nfoo = "bar\n')
 
     def test_from_file_with_quotes(self) -> None:
-        cf = self.from_file(b"[core]\n" b'foo = " bar"\n')
+        cf = self.from_file(b'[core]\nfoo = " bar"\n')
         self.assertEqual(b" bar", cf.get((b"core",), b"foo"))
 
     def test_from_file_with_interrupted_line(self) -> None:
-        cf = self.from_file(b"[core]\n" b"foo = bar\\\n" b" la\n")
+        cf = self.from_file(b"[core]\nfoo = bar\\\n la\n")
         self.assertEqual(b"barla", cf.get((b"core",), b"foo"))
 
     def test_from_file_with_boolean_setting(self) -> None:
-        cf = self.from_file(b"[core]\n" b"foo\n")
+        cf = self.from_file(b"[core]\nfoo\n")
         self.assertEqual(b"true", cf.get((b"core",), b"foo"))
 
     def test_from_file_subsection(self) -> None:
@@ -206,7 +206,7 @@ class ConfigFileTests(TestCase):
         )
         self.assertEqual(list(cf.sections()), [(b"alias",)])
         self.assertEqual(
-            b"'!f() { printf '[git commit -m \"%s\"]\n' " b'"$*" && git commit -m "$*"',
+            b'\'!f() { printf \'[git commit -m "%s"]\n\' "$*" && git commit -m "$*"',
             cf.get((b"alias",), b"c"),
         )
 

+ 2 - 3
tests/test_objects.py

@@ -1089,7 +1089,7 @@ class TagSerializeTests(TestCase):
 
 
 default_tagger = (
-    b"Linus Torvalds <torvalds@woody.linux-foundation.org> " b"1183319674 -0700"
+    b"Linus Torvalds <torvalds@woody.linux-foundation.org> 1183319674 -0700"
 )
 default_message = b"""Linux 2.6.22-rc7
 -----BEGIN PGP SIGNATURE-----
@@ -1194,8 +1194,7 @@ class TagParseTests(ShaFileCheckTests):
             Tag,
             self.make_tag_text(
                 tagger=(
-                    b"Linus Torvalds <torvalds@woody.linux-foundation.org> "
-                    b"423423+0000"
+                    b"Linus Torvalds <torvalds@woody.linux-foundation.org> 423423+0000"
                 )
             ),
         )

+ 4 - 4
tests/test_pack.py

@@ -249,7 +249,7 @@ class TestPackDeltas(TestCase):
             b"parent 20a103cc90135494162e819f98d0edfc1f1fba6b",
             b"\nauthor Victor Stinner <victor.stinner@gmail.com> 14213",
             b"10738",
-            b" +0100\ncommitter Victor Stinner <victor.stinner@gmail.com> " b"14213",
+            b" +0100\ncommitter Victor Stinner <victor.stinner@gmail.com> 14213",
             b"10738 +0100",
             b"\n\nStreamWriter: close() now clears the reference to the "
             b"transport\n\n"
@@ -1001,9 +1001,9 @@ class TestPackIterator(DeltaChainIterator):
         )
 
     def _resolve_object(self, offset, pack_type_num, base_chunks):
-        assert (
-            offset not in self._unpacked_offsets
-        ), f"Attempted to re-inflate offset {offset}"
+        assert offset not in self._unpacked_offsets, (
+            f"Attempted to re-inflate offset {offset}"
+        )
         self._unpacked_offsets.add(offset)
         return super()._resolve_object(offset, pack_type_num, base_chunks)
 

+ 3 - 3
tests/test_patch.py

@@ -91,7 +91,7 @@ Subject: [PATCH 1/2] Remove executable bit from prey.ico (triggers a warning).
         self.assertEqual(b"Jelmer Vernooij <jelmer@samba.org>", c.committer)
         self.assertEqual(b"Jelmer Vernooij <jelmer@samba.org>", c.author)
         self.assertEqual(
-            b"Remove executable bit from prey.ico " b"(triggers a warning).\n",
+            b"Remove executable bit from prey.ico (triggers a warning).\n",
             c.message,
         )
         self.assertEqual(
@@ -123,7 +123,7 @@ Subject: [PATCH 1/2] Remove executable bit from prey.ico (triggers a warning).
         self.assertEqual(b"Jelmer Vernooij <jelmer@samba.org>", c.committer)
         self.assertEqual(b"Jelmer Vernooij <jelmer@samba.org>", c.author)
         self.assertEqual(
-            b"Remove executable bit from prey.ico " b"(triggers a warning).\n",
+            b"Remove executable bit from prey.ico (triggers a warning).\n",
             c.message,
         )
         self.assertEqual(
@@ -220,7 +220,7 @@ From: Jelmer Vernooij <jelmer@debian.org>
 
     def test_extract_mercurial(self) -> NoReturn:
         raise SkipTest(
-            "git_am_patch_split doesn't handle Mercurial patches " "properly yet"
+            "git_am_patch_split doesn't handle Mercurial patches properly yet"
         )
         expected_diff = """\
 diff --git a/dulwich/tests/test_patch.py b/dulwich/tests/test_patch.py

+ 1 - 2
tests/test_repository.py

@@ -840,8 +840,7 @@ exit 1
             author_timezone=0,
         )
         expected_warning = UserWarning(
-            "post-commit hook failed: Hook post-commit exited with "
-            "non-zero status 1",
+            "post-commit hook failed: Hook post-commit exited with non-zero status 1",
         )
         for w in warnings_list:
             if type(w) is type(expected_warning) and w.args == expected_warning.args: