瀏覽代碼

Reformat with ruff

Jelmer Vernooij 11 月之前
父節點
當前提交
3317eef581

+ 6 - 3
dulwich/client.py

@@ -738,7 +738,9 @@ class GitClient:
             assert target is not None
             if origin is not None:
                 target_config = target.get_config()
-                target_config.set((b"remote", origin.encode("utf-8")), b"url", encoded_path)
+                target_config.set(
+                    (b"remote", origin.encode("utf-8")), b"url", encoded_path
+                )
                 target_config.set(
                     (b"remote", origin.encode("utf-8")),
                     b"fetch",
@@ -749,7 +751,9 @@ class GitClient:
             ref_message = b"clone: from " + encoded_path
             result = self.fetch(path, target, progress=progress, depth=depth)
             if origin is not None:
-                _import_remote_refs(target.refs, origin, result.refs, message=ref_message)
+                _import_remote_refs(
+                    target.refs, origin, result.refs, message=ref_message
+                )
 
             origin_head = result.symrefs.get(b"HEAD")
             origin_sha = result.refs.get(b"HEAD")
@@ -2225,7 +2229,6 @@ class AbstractHttpGitClient(GitClient):
 
 
 def _wrap_urllib3_exceptions(func):
-
     def wrapper(*args, **kwargs):
         try:
             return func(*args, **kwargs)

+ 4 - 4
dulwich/config.py

@@ -175,12 +175,12 @@ class Config:
         raise NotImplementedError(self.get_multivar)
 
     @overload
-    def get_boolean(self, section: SectionLike, name: NameLike, default: bool) -> bool:
-        ...
+    def get_boolean(
+        self, section: SectionLike, name: NameLike, default: bool
+    ) -> bool: ...
 
     @overload
-    def get_boolean(self, section: SectionLike, name: NameLike) -> Optional[bool]:
-        ...
+    def get_boolean(self, section: SectionLike, name: NameLike) -> Optional[bool]: ...
 
     def get_boolean(
         self, section: SectionLike, name: NameLike, default: Optional[bool] = None

+ 1 - 1
dulwich/contrib/diffstat.py

@@ -56,7 +56,7 @@ _GIT_UNCHANGED_START = b" "
 
 
 def _parse_patch(
-    lines: List[bytes]
+    lines: List[bytes],
 ) -> Tuple[List[bytes], List[bool], List[Tuple[int, int]]]:
     """Parse a git style diff or patch to generate diff stats.
 

+ 1 - 0
dulwich/contrib/requests_vendor.py

@@ -29,6 +29,7 @@ the dulwich.client.HttpGitClient attribute:
 
 This implementation is experimental and does not have any tests.
 """
+
 from io import BytesIO
 
 from requests import Session

+ 1 - 0
dulwich/credentials.py

@@ -24,6 +24,7 @@
 https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
 
 """
+
 import sys
 from typing import Iterator, Optional
 from urllib.parse import ParseResult, urlparse

+ 0 - 1
dulwich/errors.py

@@ -25,7 +25,6 @@
 # Please do not add more errors here, but instead add them close to the code
 # that raises the error.
 
-
 import binascii
 
 

+ 1 - 1
dulwich/index.py

@@ -519,7 +519,7 @@ class Index:
         del self._byname[name]
 
     def iteritems(
-        self
+        self,
     ) -> Iterator[Tuple[bytes, Union[IndexEntry, ConflictedIndexEntry]]]:
         return iter(self._byname.items())
 

+ 1 - 1
dulwich/objects.py

@@ -670,7 +670,7 @@ class Blob(ShaFile):
 
 
 def _parse_message(
-    chunks: Iterable[bytes]
+    chunks: Iterable[bytes],
 ) -> Iterator[Union[Tuple[None, None], Tuple[Optional[bytes], bytes]]]:
     """Parse a message with a list of fields and a body.
 

+ 2 - 2
dulwich/pack.py

@@ -1829,7 +1829,7 @@ def deltify_pack_objects(
 
 
 def sort_objects_for_delta(
-    objects: Union[Iterator[ShaFile], Iterator[Tuple[ShaFile, Optional[PackHint]]]]
+    objects: Union[Iterator[ShaFile], Iterator[Tuple[ShaFile, Optional[PackHint]]]],
 ) -> Iterator[ShaFile]:
     magic = []
     for entry in objects:
@@ -2781,7 +2781,7 @@ def extend_pack(
 try:
     from dulwich._pack import (  # type: ignore
         apply_delta,  # type: ignore
-                               bisect_find_sha,  # type: ignore
+        bisect_find_sha,  # type: ignore
     )
 except ImportError:
     pass

+ 1 - 0
dulwich/refs.py

@@ -20,6 +20,7 @@
 
 
 """Ref handling."""
+
 import os
 import warnings
 from contextlib import suppress

+ 0 - 1
dulwich/stash.py

@@ -20,7 +20,6 @@
 
 """Stash handling."""
 
-
 import os
 
 from .file import GitFile

+ 0 - 1
dulwich/tests/compat/test_pack.py

@@ -20,7 +20,6 @@
 
 """Compatibility tests for git packs."""
 
-
 import binascii
 import os
 import re

+ 1 - 0
dulwich/tests/compat/test_patch.py

@@ -19,6 +19,7 @@
 #
 
 """Tests related to patch compatibility with CGit."""
+
 import os
 import shutil
 import tempfile

+ 0 - 1
dulwich/tests/compat/test_repository.py

@@ -20,7 +20,6 @@
 
 """Compatibility tests for dulwich repositories."""
 
-
 import os
 import tempfile
 from io import BytesIO

+ 3 - 3
dulwich/tests/test_client.py

@@ -772,9 +772,9 @@ class SSHGitClientTests(TestCase):
         )
 
     def test_alternative_command_path_spaces(self):
-        self.client.alternative_paths[
-            b"upload-pack"
-        ] = b"/usr/lib/git/git-upload-pack -ibla"
+        self.client.alternative_paths[b"upload-pack"] = (
+            b"/usr/lib/git/git-upload-pack -ibla"
+        )
         self.assertEqual(
             b"/usr/lib/git/git-upload-pack -ibla",
             self.client._get_cmd_path(b"upload-pack"),

+ 0 - 1
dulwich/tests/test_index.py

@@ -20,7 +20,6 @@
 
 """Tests for the index."""
 
-
 import os
 import shutil
 import stat

+ 0 - 1
dulwich/tests/test_object_store.py

@@ -20,7 +20,6 @@
 
 """Tests for the object store interface."""
 
-
 import os
 import shutil
 import stat

+ 0 - 1
dulwich/tests/test_objects.py

@@ -22,7 +22,6 @@
 
 # TODO: Round-trip parse-serialize-parse and serialize-parse-serialize tests.
 
-
 import datetime
 import os
 import stat

+ 0 - 1
dulwich/tests/test_objectspec.py

@@ -22,7 +22,6 @@
 
 # TODO: Round-trip parse-serialize-parse and serialize-parse-serialize tests.
 
-
 from dulwich.tests import TestCase
 
 from ..objects import Blob

+ 0 - 1
dulwich/tests/test_pack.py

@@ -21,7 +21,6 @@
 
 """Tests for Dulwich packs."""
 
-
 import os
 import shutil
 import sys

+ 0 - 1
dulwich/tests/test_protocol.py

@@ -20,7 +20,6 @@
 
 """Tests for the smart protocol utility functions."""
 
-
 from io import BytesIO
 
 from dulwich.tests import TestCase

+ 6 - 6
dulwich/tests/test_refs.py

@@ -316,9 +316,9 @@ class RefsContainerTests:
         self.assertNotIn(b"refs/tags/refs-0.2", self._refs)
 
     def test_import_refs_name(self):
-        self._refs[
-            b"refs/remotes/origin/other"
-        ] = b"48d01bd4b77fed026b154d16493e5deab78f02ec"
+        self._refs[b"refs/remotes/origin/other"] = (
+            b"48d01bd4b77fed026b154d16493e5deab78f02ec"
+        )
         self._refs.import_refs(
             b"refs/remotes/origin",
             {b"master": b"42d06bd4b77fed026b154d16493e5deab78f02ec"},
@@ -333,9 +333,9 @@ class RefsContainerTests:
         )
 
     def test_import_refs_name_prune(self):
-        self._refs[
-            b"refs/remotes/origin/other"
-        ] = b"48d01bd4b77fed026b154d16493e5deab78f02ec"
+        self._refs[b"refs/remotes/origin/other"] = (
+            b"48d01bd4b77fed026b154d16493e5deab78f02ec"
+        )
         self._refs.import_refs(
             b"refs/remotes/origin",
             {b"master": b"42d06bd4b77fed026b154d16493e5deab78f02ec"},

+ 0 - 1
dulwich/tests/utils.py

@@ -20,7 +20,6 @@
 
 """Utility functions common to Dulwich tests."""
 
-
 import datetime
 import os
 import shutil

+ 0 - 1
dulwich/walk.py

@@ -20,7 +20,6 @@
 
 """General implementation of walking commits and their contents."""
 
-
 import collections
 import heapq
 from itertools import chain

+ 0 - 1
examples/clone.py

@@ -8,7 +8,6 @@ Example usage:
   3. python examples/clone.py git://github.com/jelmer/dulwich.git dulwich
 """
 
-
 import sys
 from getopt import getopt
 from os.path import basename

+ 23 - 6
setup.py

@@ -36,9 +36,24 @@ if "__pypy__" not in sys.modules and sys.platform != "win32":
 optional = os.environ.get("CIBUILDWHEEL", "0") != "1"
 
 rust_extensions = [
-    RustExtension("dulwich._objects", "crates/objects/Cargo.toml", binding=Binding.PyO3, optional=optional),
-    RustExtension("dulwich._pack", "crates/pack/Cargo.toml", binding=Binding.PyO3, optional=optional),
-    RustExtension("dulwich._diff_tree", "crates/diff-tree/Cargo.toml", binding=Binding.PyO3, optional=optional),
+    RustExtension(
+        "dulwich._objects",
+        "crates/objects/Cargo.toml",
+        binding=Binding.PyO3,
+        optional=optional,
+    ),
+    RustExtension(
+        "dulwich._pack",
+        "crates/pack/Cargo.toml",
+        binding=Binding.PyO3,
+        optional=optional,
+    ),
+    RustExtension(
+        "dulwich._diff_tree",
+        "crates/diff-tree/Cargo.toml",
+        binding=Binding.PyO3,
+        optional=optional,
+    ),
 ]
 
 # Ideally, setuptools would just provide a way to do this
@@ -47,6 +62,8 @@ if "--pure" in sys.argv:
     rust_extensions = []
 
 
-setup(package_data={'': ['../docs/tutorial/*.txt', 'py.typed']},
-      rust_extensions=rust_extensions,
-      tests_require=tests_require)
+setup(
+    package_data={"": ["../docs/tutorial/*.txt", "py.typed"]},
+    rust_extensions=rust_extensions,
+    tests_require=tests_require,
+)