diff --git a/dulwich/client.py b/dulwich/client.py index 065cfd935..7e2bbe455 100644 --- a/dulwich/client.py +++ b/dulwich/client.py @@ -738,7 +738,9 @@ def clone( 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 @@ def clone( 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 @@ def __repr__(self) -> str: def _wrap_urllib3_exceptions(func): - def wrapper(*args, **kwargs): try: return func(*args, **kwargs) diff --git a/dulwich/config.py b/dulwich/config.py index 19f35ce31..bfd61c591 100644 --- a/dulwich/config.py +++ b/dulwich/config.py @@ -175,12 +175,12 @@ def get_multivar(self, section: SectionLike, name: NameLike) -> Iterator[Value]: 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 diff --git a/dulwich/contrib/diffstat.py b/dulwich/contrib/diffstat.py index 6b44eea3e..803c009ea 100755 --- a/dulwich/contrib/diffstat.py +++ b/dulwich/contrib/diffstat.py @@ -56,7 +56,7 @@ 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. diff --git a/dulwich/contrib/requests_vendor.py b/dulwich/contrib/requests_vendor.py index 89012677c..b556f3148 100644 --- a/dulwich/contrib/requests_vendor.py +++ b/dulwich/contrib/requests_vendor.py @@ -29,6 +29,7 @@ This implementation is experimental and does not have any tests. """ + from io import BytesIO from requests import Session diff --git a/dulwich/credentials.py b/dulwich/credentials.py index 960f812e1..05de0452d 100644 --- a/dulwich/credentials.py +++ b/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 diff --git a/dulwich/errors.py b/dulwich/errors.py index 841d45552..3300b7457 100644 --- a/dulwich/errors.py +++ b/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 diff --git a/dulwich/index.py b/dulwich/index.py index f7b9adbc7..5345acc2f 100644 --- a/dulwich/index.py +++ b/dulwich/index.py @@ -519,7 +519,7 @@ def __delitem__(self, name: bytes) -> None: del self._byname[name] def iteritems( - self + self, ) -> Iterator[Tuple[bytes, Union[IndexEntry, ConflictedIndexEntry]]]: return iter(self._byname.items()) diff --git a/dulwich/objects.py b/dulwich/objects.py index a241646d0..9fe5fbd7c 100644 --- a/dulwich/objects.py +++ b/dulwich/objects.py @@ -670,7 +670,7 @@ def splitlines(self) -> List[bytes]: 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. diff --git a/dulwich/pack.py b/dulwich/pack.py index 7578a908a..6b1af8737 100644 --- a/dulwich/pack.py +++ b/dulwich/pack.py @@ -1829,7 +1829,7 @@ def objects_with_hints(): 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 diff --git a/dulwich/refs.py b/dulwich/refs.py index 42ddcfe02..b3d324b23 100644 --- a/dulwich/refs.py +++ b/dulwich/refs.py @@ -20,6 +20,7 @@ """Ref handling.""" + import os import warnings from contextlib import suppress diff --git a/dulwich/stash.py b/dulwich/stash.py index 51624253a..0b577241a 100644 --- a/dulwich/stash.py +++ b/dulwich/stash.py @@ -20,7 +20,6 @@ """Stash handling.""" - import os from .file import GitFile diff --git a/dulwich/tests/compat/test_pack.py b/dulwich/tests/compat/test_pack.py index 993603a95..351351a5d 100644 --- a/dulwich/tests/compat/test_pack.py +++ b/dulwich/tests/compat/test_pack.py @@ -20,7 +20,6 @@ """Compatibility tests for git packs.""" - import binascii import os import re diff --git a/dulwich/tests/compat/test_patch.py b/dulwich/tests/compat/test_patch.py index 08c10e249..aa33f0db7 100644 --- a/dulwich/tests/compat/test_patch.py +++ b/dulwich/tests/compat/test_patch.py @@ -19,6 +19,7 @@ # """Tests related to patch compatibility with CGit.""" + import os import shutil import tempfile diff --git a/dulwich/tests/compat/test_repository.py b/dulwich/tests/compat/test_repository.py index 4904a33d3..3ab51a67e 100644 --- a/dulwich/tests/compat/test_repository.py +++ b/dulwich/tests/compat/test_repository.py @@ -20,7 +20,6 @@ """Compatibility tests for dulwich repositories.""" - import os import tempfile from io import BytesIO diff --git a/dulwich/tests/test_client.py b/dulwich/tests/test_client.py index 9af8b8822..72eebc3e3 100644 --- a/dulwich/tests/test_client.py +++ b/dulwich/tests/test_client.py @@ -772,9 +772,9 @@ def test_alternative_command_path(self): ) 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"), diff --git a/dulwich/tests/test_index.py b/dulwich/tests/test_index.py index b9a72b5db..28c041dc3 100644 --- a/dulwich/tests/test_index.py +++ b/dulwich/tests/test_index.py @@ -20,7 +20,6 @@ """Tests for the index.""" - import os import shutil import stat diff --git a/dulwich/tests/test_object_store.py b/dulwich/tests/test_object_store.py index 0dc9bea66..fc026082f 100644 --- a/dulwich/tests/test_object_store.py +++ b/dulwich/tests/test_object_store.py @@ -20,7 +20,6 @@ """Tests for the object store interface.""" - import os import shutil import stat diff --git a/dulwich/tests/test_objects.py b/dulwich/tests/test_objects.py index 9ea60ee96..8b8b5b5e6 100644 --- a/dulwich/tests/test_objects.py +++ b/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 diff --git a/dulwich/tests/test_objectspec.py b/dulwich/tests/test_objectspec.py index 10015c4ec..0e3476e55 100644 --- a/dulwich/tests/test_objectspec.py +++ b/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 diff --git a/dulwich/tests/test_pack.py b/dulwich/tests/test_pack.py index 2c211c2b6..d8fa4c1e3 100644 --- a/dulwich/tests/test_pack.py +++ b/dulwich/tests/test_pack.py @@ -21,7 +21,6 @@ """Tests for Dulwich packs.""" - import os import shutil import sys diff --git a/dulwich/tests/test_protocol.py b/dulwich/tests/test_protocol.py index e20391937..3d12d1835 100644 --- a/dulwich/tests/test_protocol.py +++ b/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 diff --git a/dulwich/tests/test_refs.py b/dulwich/tests/test_refs.py index ec3d0904b..21f6bb87f 100644 --- a/dulwich/tests/test_refs.py +++ b/dulwich/tests/test_refs.py @@ -316,9 +316,9 @@ def test_remove_if_equals(self): 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 @@ def test_import_refs_name(self): ) 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"}, diff --git a/dulwich/tests/utils.py b/dulwich/tests/utils.py index cdd235bea..22f528645 100644 --- a/dulwich/tests/utils.py +++ b/dulwich/tests/utils.py @@ -20,7 +20,6 @@ """Utility functions common to Dulwich tests.""" - import datetime import os import shutil diff --git a/dulwich/walk.py b/dulwich/walk.py index c0db19e40..93bd5bbb7 100644 --- a/dulwich/walk.py +++ b/dulwich/walk.py @@ -20,7 +20,6 @@ """General implementation of walking commits and their contents.""" - import collections import heapq from itertools import chain diff --git a/examples/clone.py b/examples/clone.py index cafde9e9c..33e8531ff 100644 --- a/examples/clone.py +++ b/examples/clone.py @@ -8,7 +8,6 @@ 3. python examples/clone.py git://github.com/jelmer/dulwich.git dulwich """ - import sys from getopt import getopt from os.path import basename diff --git a/setup.py b/setup.py index d719c6e3a..7d1362aeb 100755 --- a/setup.py +++ b/setup.py @@ -36,9 +36,24 @@ 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 @@ 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, +)