Jelajahi Sumber

Fix formatting

Jelmer Vernooij 1 bulan lalu
induk
melakukan
94ee8dad53
6 mengubah file dengan 41 tambahan dan 23 penghapusan
  1. 2 2
      dulwich/cli.py
  2. 7 5
      dulwich/contrib/swift.py
  3. 4 4
      dulwich/dumb.py
  4. 1 3
      dulwich/pack.py
  5. 1 3
      tests/compat/server_utils.py
  6. 26 6
      tests/test_pack.py

+ 2 - 2
dulwich/cli.py

@@ -1606,9 +1606,9 @@ class cmd_dump_pack(Command):
         )
         )
         parsed_args = parser.parse_args(args)
         parsed_args = parser.parse_args(args)
 
 
-        from .object_format import OBJECT_FORMAT_NAMES
+        from .object_format import OBJECT_FORMATS
 
 
-        object_format = OBJECT_FORMAT_NAMES[parsed_args.object_format]
+        object_format = OBJECT_FORMATS[parsed_args.object_format]
         basename, _ = os.path.splitext(parsed_args.filename)
         basename, _ = os.path.splitext(parsed_args.filename)
         x = Pack(basename, object_format=object_format)
         x = Pack(basename, object_format=object_format)
         logger.info("Object names checksum: %s", x.name().decode("ascii", "replace"))
         logger.info("Object names checksum: %s", x.name().decode("ascii", "replace"))

+ 7 - 5
dulwich/contrib/swift.py

@@ -226,9 +226,7 @@ def pack_info_create(pack_data: "PackData", pack_index: "PackIndex") -> bytes:
     Returns:
     Returns:
       Compressed JSON bytes containing pack information
       Compressed JSON bytes containing pack information
     """
     """
-    pack = Pack.from_objects(
-        pack_data, pack_index
-    )
+    pack = Pack.from_objects(pack_data, pack_index)
     info: dict[bytes, Any] = {}
     info: dict[bytes, Any] = {}
     for obj in pack.iterobjects():
     for obj in pack.iterobjects():
         # Commit
         # Commit
@@ -895,7 +893,9 @@ class SwiftObjectStore(PackBasedObjectStore):
                 f.close()
                 f.close()
                 self.scon.put_object(basename + ".idx", index)
                 self.scon.put_object(basename + ".idx", index)
                 index.close()
                 index.close()
-                final_pack = SwiftPack(basename, object_format=self.object_format, scon=self.scon)
+                final_pack = SwiftPack(
+                    basename, object_format=self.object_format, scon=self.scon
+                )
                 final_pack.check_length_and_checksum()
                 final_pack.check_length_and_checksum()
                 self._add_cached_pack(basename, final_pack)
                 self._add_cached_pack(basename, final_pack)
                 return final_pack
                 return final_pack
@@ -1020,7 +1020,9 @@ class SwiftObjectStore(PackBasedObjectStore):
         pack_info_file.close()
         pack_info_file.close()
 
 
         # Add the pack to the store and return it.
         # Add the pack to the store and return it.
-        final_pack = SwiftPack(pack_base_name, object_format=self.object_format, scon=self.scon)
+        final_pack = SwiftPack(
+            pack_base_name, object_format=self.object_format, scon=self.scon
+        )
         final_pack.check_length_and_checksum()
         final_pack.check_length_and_checksum()
         self._add_cached_pack(pack_base_name, final_pack)
         self._add_cached_pack(pack_base_name, final_pack)
         return final_pack
         return final_pack

+ 4 - 4
dulwich/dumb.py

@@ -208,7 +208,9 @@ class DumbHTTPObjectStore(BaseObjectStore):
                     # Fetch and cache the index
                     # Fetch and cache the index
                     idx_data = self._fetch_url(f"objects/pack/{pack_name}.idx")
                     idx_data = self._fetch_url(f"objects/pack/{pack_name}.idx")
 
 
-                    idx = load_pack_index_file("<http>", BytesIO(idx_data), self.object_format)
+                    idx = load_pack_index_file(
+                        "<http>", BytesIO(idx_data), self.object_format
+                    )
                     if self._packs is not None:
                     if self._packs is not None:
                         self._packs[i] = (name, idx)
                         self._packs[i] = (name, idx)
                 return idx
                 return idx
@@ -259,9 +261,7 @@ class DumbHTTPObjectStore(BaseObjectStore):
 
 
             # Open the pack and get the object
             # Open the pack and get the object
             pack_data = PackData(pack_path, object_format=self.object_format)
             pack_data = PackData(pack_path, object_format=self.object_format)
-            pack = Pack.from_objects(
-                pack_data, pack_idx
-            )
+            pack = Pack.from_objects(pack_data, pack_idx)
             try:
             try:
                 return pack.get_raw(binsha)
                 return pack.get_raw(binsha)
             finally:
             finally:

+ 1 - 3
dulwich/pack.py

@@ -605,9 +605,7 @@ def load_pack_index_file(
                 size=size,
                 size=size,
             )
             )
         elif version == 3:
         elif version == 3:
-            return PackIndex3(
-                path, object_format, file=f, contents=contents, size=size
-            )
+            return PackIndex3(path, object_format, file=f, contents=contents, size=size)
         else:
         else:
             raise KeyError(f"Unknown pack index format {version}")
             raise KeyError(f"Unknown pack index format {version}")
     else:
     else:

+ 1 - 3
tests/compat/server_utils.py

@@ -351,9 +351,7 @@ class NoSideBand64kReceivePackHandler(ReceivePackHandler):
     """ReceivePackHandler that does not support side-band-64k."""
     """ReceivePackHandler that does not support side-band-64k."""
 
 
     def capabilities(self):
     def capabilities(self):
-        return [
-            c for c in super().capabilities() if c != CAPABILITY_SIDE_BAND_64K
-        ]
+        return [c for c in super().capabilities() if c != CAPABILITY_SIDE_BAND_64K]
 
 
 
 
 def ignore_error(error):
 def ignore_error(error):

+ 26 - 6
tests/test_pack.py

@@ -613,15 +613,21 @@ class TestPackData(PackTests):
             )
             )
             self.assertEqual(
             self.assertEqual(
                 sha1(b"abcd1234wxyz").hexdigest(),
                 sha1(b"abcd1234wxyz").hexdigest(),
-                compute_file_sha(f, DEFAULT_OBJECT_FORMAT.hash_func, buffer_size=5).hexdigest(),
+                compute_file_sha(
+                    f, DEFAULT_OBJECT_FORMAT.hash_func, buffer_size=5
+                ).hexdigest(),
             )
             )
             self.assertEqual(
             self.assertEqual(
                 sha1(b"abcd1234").hexdigest(),
                 sha1(b"abcd1234").hexdigest(),
-                compute_file_sha(f, DEFAULT_OBJECT_FORMAT.hash_func, end_ofs=-4).hexdigest(),
+                compute_file_sha(
+                    f, DEFAULT_OBJECT_FORMAT.hash_func, end_ofs=-4
+                ).hexdigest(),
             )
             )
             self.assertEqual(
             self.assertEqual(
                 sha1(b"1234wxyz").hexdigest(),
                 sha1(b"1234wxyz").hexdigest(),
-                compute_file_sha(f, DEFAULT_OBJECT_FORMAT.hash_func, start_ofs=4).hexdigest(),
+                compute_file_sha(
+                    f, DEFAULT_OBJECT_FORMAT.hash_func, start_ofs=4
+                ).hexdigest(),
             )
             )
             self.assertEqual(
             self.assertEqual(
                 sha1(b"1234").hexdigest(),
                 sha1(b"1234").hexdigest(),
@@ -636,13 +642,27 @@ class TestPackData(PackTests):
         f = BytesIO(b"abcd1234wxyz")
         f = BytesIO(b"abcd1234wxyz")
         try:
         try:
             self.assertRaises(
             self.assertRaises(
-                AssertionError, compute_file_sha, f, DEFAULT_OBJECT_FORMAT.hash_func, -20
+                AssertionError,
+                compute_file_sha,
+                f,
+                DEFAULT_OBJECT_FORMAT.hash_func,
+                -20,
             )
             )
             self.assertRaises(
             self.assertRaises(
-                AssertionError, compute_file_sha, f, DEFAULT_OBJECT_FORMAT.hash_func, 0, 20
+                AssertionError,
+                compute_file_sha,
+                f,
+                DEFAULT_OBJECT_FORMAT.hash_func,
+                0,
+                20,
             )
             )
             self.assertRaises(
             self.assertRaises(
-                AssertionError, compute_file_sha, f, DEFAULT_OBJECT_FORMAT.hash_func, 10, -12
+                AssertionError,
+                compute_file_sha,
+                f,
+                DEFAULT_OBJECT_FORMAT.hash_func,
+                10,
+                -12,
             )
             )
         finally:
         finally:
             f.close()
             f.close()