commit - ce10dd1ea24c4100428ebe322e17c73c73ae3474
commit + 26246d71f3ba583c13c99c25114cc2396da836b4
blob - 0011d02259c9d6d075f7be453fb014257758f0a7
blob + ddbbb2608f5a854380539c12e6ba871564aa6cf8
--- dulwich/client.py
+++ dulwich/client.py
COMMON_CAPABILITIES = [CAPABILITY_OFS_DELTA, CAPABILITY_SIDE_BAND_64K]
-UPLOAD_CAPABILITIES = [CAPABILITY_THIN_PACK, CAPABILITY_MULTI_ACK, CAPABILITY_MULTI_ACK_DETAILED, CAPABILITY_SHALLOW, *COMMON_CAPABILITIES]
-RECEIVE_CAPABILITIES = [CAPABILITY_REPORT_STATUS, CAPABILITY_DELETE_REFS, *COMMON_CAPABILITIES]
+UPLOAD_CAPABILITIES = [
+ CAPABILITY_THIN_PACK,
+ CAPABILITY_MULTI_ACK,
+ CAPABILITY_MULTI_ACK_DETAILED,
+ CAPABILITY_SHALLOW,
+ *COMMON_CAPABILITIES,
+]
+RECEIVE_CAPABILITIES = [
+ CAPABILITY_REPORT_STATUS,
+ CAPABILITY_DELETE_REFS,
+ *COMMON_CAPABILITIES,
+]
class ReportStatusParser:
k, v = parse_capability(capability)
if k == CAPABILITY_AGENT:
agent = v
- unknown_capabilities = ( # noqa: F841
- extract_capability_names(server_capabilities) - KNOWN_RECEIVE_CAPABILITIES
- )
+ (extract_capability_names(server_capabilities) - KNOWN_RECEIVE_CAPABILITIES)
# TODO(jelmer): warn about unknown capabilities
return negotiated_capabilities, agent
return None
def _negotiate_upload_pack_capabilities(self, server_capabilities):
- unknown_capabilities = ( # noqa: F841
- extract_capability_names(server_capabilities) - KNOWN_UPLOAD_CAPABILITIES
- )
+ (extract_capability_names(server_capabilities) - KNOWN_UPLOAD_CAPABILITIES)
# TODO(jelmer): warn about unknown capabilities
symrefs = {}
agent = None
cmd: The git service name to which we should connect.
path: The path we should pass to the service. (as bytestirng)
"""
- raise NotImplementedError()
+ raise NotImplementedError
def send_pack(self, path, update_refs, generate_pack_data, progress=None):
"""Upload a pack to a remote repository.
if ssh_command:
import shlex
+
args = [*shlex.split(ssh_command, posix=sys.platform != "win32"), "-x"]
else:
args = ["ssh", "-x"]
):
if ssh_command:
import shlex
+
args = [*shlex.split(ssh_command, posix=sys.platform != "win32"), "-ssh"]
elif sys.platform == "win32":
args = ["plink.exe", "-ssh"]
raise GitProtocolError(str(e)) from e
if resp.status == 404:
- raise NotGitRepository()
+ raise NotGitRepository
if resp.status == 401:
raise HTTPUnauthorized(resp.headers.get("WWW-Authenticate"), url)
if resp.status == 407:
blob - 57af8991566be1982fe87e2daf2457ae057ba10a
blob + 19f35ce31de8b5488a569b9f742b26e7434e67d1
--- dulwich/config.py
+++ dulwich/config.py
def _format_string(value: bytes) -> bytes:
if (
- value.startswith(b" ")
- or value.startswith(b"\t")
- or value.endswith(b" ")
+ value.startswith((b" ", b"\t"))
+ or value.endswith((b" ", b"\t"))
or b"#" in value
- or value.endswith(b"\t")
):
return b'"' + _escape_value(value) + b'"'
else:
blob - bd3e0767dfd307c8e79fa80683da9b4c2143f857
blob + 89012677c04fb8e77b6f4df88d1ed21515aa0994
--- dulwich/contrib/requests_vendor.py
+++ dulwich/contrib/requests_vendor.py
resp = self.session.get(url, headers=req_headers)
if resp.status_code == 404:
- raise NotGitRepository()
+ raise NotGitRepository
if resp.status_code == 401:
raise HTTPUnauthorized(resp.headers.get("WWW-Authenticate"), url)
if resp.status_code == 407:
blob - 9280bd026273ea3a650443380885f6c3b4513825
blob + 588e4e24428de3565f982884a49a3b9698cb29b2
--- dulwich/contrib/swift.py
+++ dulwich/contrib/swift.py
o_store for o_store in catalogs if o_store["type"] == "object-store"
)
endpoints = object_store["endpoints"]
- endpoint = next(endp for endp in endpoints if endp["region"] == self.region_name)
+ endpoint = next(
+ endp for endp in endpoints if endp["region"] == self.region_name
+ )
return endpoint[self.endpoint_type], token
def test_root_exists(self):
blob - 1f8756f4cba991159a3e43a954eb29ac1263e271
blob + 7e8ed261b8c47bc1d7b663a4574e91931880cc98
--- dulwich/contrib/test_release_robot.py
+++ dulwich/contrib/test_release_robot.py
test_repo = os.path.join(BASEDIR, "dulwich_test_repo.zip")
committer = b"Mark Mikofski <mark.mikofski@sunpowercorp.com>"
test_tags: ClassVar[List[bytes]] = [b"v0.1a", b"v0.1"]
- tag_test_data: ClassVar[Dict[bytes, Tuple[int, bytes, Optional[Tuple[int, bytes]]]]] = {
+ tag_test_data: ClassVar[
+ Dict[bytes, Tuple[int, bytes, Optional[Tuple[int, bytes]]]]
+ ] = {
test_tags[0]: (1484788003, b"3" * 40, None),
test_tags[1]: (1484788314, b"1" * 40, (1484788401, b"2" * 40)),
}
blob - ff1352138d49a02f0b6895c0e0e453a7a9a01119
blob + 32015c225076acdc6e13bfd76727c7682622f88b
--- dulwich/contrib/test_swift.py
+++ dulwich/contrib/test_swift.py
missing_libs = []
try:
- import gevent # noqa:F401
+ import gevent # noqa: F401
except ModuleNotFoundError:
missing_libs.append("gevent")
try:
- import geventhttpclient # noqa:F401
+ import geventhttpclient # noqa: F401
except ModuleNotFoundError:
missing_libs.append("geventhttpclient")
def create_commits(length=1, marker=b"Default"):
data = []
- for i in range(0, length):
+ for i in range(length):
_marker = (f"{marker}_{i}").encode()
blob, tree, tag, cmt = create_commit(data, _marker)
data.extend([blob, tree, tag, cmt])
blob - 3c520c62c1e30e7a51d502f0decfc5b1581dd361
blob + 2a19f6df2b680aeb87dcd5e56cdd3e03e22b9942
--- dulwich/contrib/test_swift_smoke.py
+++ dulwich/contrib/test_swift_smoke.py
monkey.patch_all()
-from dulwich import client, index, objects, repo, server # noqa:E402
-from dulwich.contrib import swift # noqa:E402
+from dulwich import client, index, objects, repo, server # noqa: E402
+from dulwich.contrib import swift # noqa: E402
class DulwichServer:
blob - c5a367196d6757f0f4b8803cd6961e7f906be748
blob + 4263d0d9695ef509fe320cb62f442b599a5d2bcc
--- dulwich/fastexport.py
+++ dulwich/fastexport.py
def checkpoint_handler(self, cmd):
"""Process a CheckpointCommand."""
- pass
def commit_handler(self, cmd):
"""Process a CommitCommand."""
def progress_handler(self, cmd):
"""Process a ProgressCommand."""
- pass
def _reset_base(self, commit_id):
if self.last_commit == commit_id:
blob - 16a4b49a9d1a051fc643cd84c4d8b012022226ea
blob + b1f56fc573b2539de62a69987e4a6b8a12cc6ca9
--- dulwich/hooks.py
+++ dulwich/hooks.py
try:
ret = subprocess.call(
- [os.path.relpath(self.filepath, self.cwd), *list(args)],
- cwd=self.cwd)
+ [os.path.relpath(self.filepath, self.cwd), *list(args)], cwd=self.cwd
+ )
if ret != 0:
if self.post_exec_callback is not None:
self.post_exec_callback(0, *args)
blob - 739f5c4f6fba0aa77d91442fb5514a67807dc941
blob + f7b9adbc78f05c2f002b105c6f545e0a9ba3b567
--- dulwich/index.py
+++ dulwich/index.py
"""Return the (git object) SHA1 for the object at a path."""
value = self[path]
if isinstance(value, ConflictedIndexEntry):
- raise UnmergedEntries()
+ raise UnmergedEntries
return value.sha
def get_mode(self, path: bytes) -> int:
"""Return the POSIX file mode for the object at a path."""
value = self[path]
if isinstance(value, ConflictedIndexEntry):
- raise UnmergedEntries()
+ raise UnmergedEntries
return value.mode
def iterobjects(self) -> Iterable[Tuple[bytes, bytes, int]]:
for path in self:
entry = self[path]
if isinstance(entry, ConflictedIndexEntry):
- raise UnmergedEntries()
+ raise UnmergedEntries
yield path, entry.sha, cleanup_mode(entry.mode)
def has_conflicts(self) -> bool:
blob - d7c042179c00dd629c0dbf766719b6d9c628ab69
blob + 2821176546cd6d7395021a78d35afe42bb0b36fa
--- dulwich/pack.py
+++ dulwich/pack.py
return (
count,
deltify_pack_objects(
- iter(objects), window_size=delta_window_size, progress=progress # type: ignore
+ iter(objects), # type: ignore
+ window_size=delta_window_size,
+ progress=progress,
),
)
else:
blob - b15ef08e6b469721c2ed3551c5ee0dc96d28be13
blob + aa6ae410a1e128cb3cbe99b9eb4a61a02c57c985
--- dulwich/porcelain.py
+++ dulwich/porcelain.py
raise Error("target_dir must be in the repo's working dir")
config = r.get_config_stack()
- require_force = config.get_boolean( # noqa: F841
- (b"clean",), b"requireForce", True
- )
+ config.get_boolean((b"clean",), b"requireForce", True)
# TODO(jelmer): if require_force is set, then make sure that -f, -i or
# -n is specified.
blob - 2725795e7fae60c0f16406e40bbdfc23a5b5ee09
blob + de2618779071a60d78270ed38abfb4f5b95e5025
--- dulwich/protocol.py
+++ dulwich/protocol.py
CAPABILITY_NO_PROGRESS,
]
KNOWN_UPLOAD_CAPABILITIES = set(
- [*COMMON_CAPABILITIES, CAPABILITY_THIN_PACK, CAPABILITY_MULTI_ACK, CAPABILITY_MULTI_ACK_DETAILED, CAPABILITY_INCLUDE_TAG, CAPABILITY_DEEPEN_SINCE, CAPABILITY_SYMREF, CAPABILITY_SHALLOW, CAPABILITY_DEEPEN_NOT, CAPABILITY_DEEPEN_RELATIVE, CAPABILITY_ALLOW_TIP_SHA1_IN_WANT, CAPABILITY_ALLOW_REACHABLE_SHA1_IN_WANT]
+ [
+ *COMMON_CAPABILITIES,
+ CAPABILITY_THIN_PACK,
+ CAPABILITY_MULTI_ACK,
+ CAPABILITY_MULTI_ACK_DETAILED,
+ CAPABILITY_INCLUDE_TAG,
+ CAPABILITY_DEEPEN_SINCE,
+ CAPABILITY_SYMREF,
+ CAPABILITY_SHALLOW,
+ CAPABILITY_DEEPEN_NOT,
+ CAPABILITY_DEEPEN_RELATIVE,
+ CAPABILITY_ALLOW_TIP_SHA1_IN_WANT,
+ CAPABILITY_ALLOW_REACHABLE_SHA1_IN_WANT,
+ ]
)
KNOWN_RECEIVE_CAPABILITIES = set(
- [*COMMON_CAPABILITIES, CAPABILITY_REPORT_STATUS, CAPABILITY_DELETE_REFS, CAPABILITY_QUIET, CAPABILITY_ATOMIC]
+ [
+ *COMMON_CAPABILITIES,
+ CAPABILITY_REPORT_STATUS,
+ CAPABILITY_DELETE_REFS,
+ CAPABILITY_QUIET,
+ CAPABILITY_ATOMIC,
+ ]
)
DEPTH_INFINITE = 0x7FFFFFFF
try:
sizestr = read(4)
if not sizestr:
- raise HangupException()
+ raise HangupException
size = int(sizestr, 16)
if size == 0 or size == 1: # flush-pkt or delim-pkt
if self.report_activity:
self.report_activity(size, "read")
pkt_contents = read(size - 4)
except ConnectionResetError as exc:
- raise HangupException() from exc
+ raise HangupException from exc
except OSError as exc:
raise GitProtocolError(str(exc)) from exc
else:
blob - 745ba78d451386421aea6f116ecccf863a25a012
blob + d87c93382b8d392870534e8be78d2f3dcc2eecbe
--- dulwich/repo.py
+++ dulwich/repo.py
valid_hexsha,
)
from .pack import generate_unpacked_objects
-from .refs import ( # noqa: F401
- ANNOTATED_TAG_SUFFIX,
+from .refs import (
+ ANNOTATED_TAG_SUFFIX, # noqa: F401
LOCAL_BRANCH_PREFIX,
- LOCAL_TAG_PREFIX,
- SYMREF,
+ LOCAL_TAG_PREFIX, # noqa: F401
+ SYMREF, # noqa: F401
DictRefsContainer,
DiskRefsContainer,
- InfoRefsContainer,
+ InfoRefsContainer, # noqa: F401
Ref,
RefsContainer,
_set_default_branch,
_set_head,
_set_origin_head,
- check_ref_format,
- read_packed_refs,
- read_packed_refs_with_peeled,
+ check_ref_format, # noqa: F401
+ read_packed_refs, # noqa: F401
+ read_packed_refs_with_peeled, # noqa: F401
serialize_refs,
- write_packed_refs,
+ write_packed_refs, # noqa: F401
)
CONTROLDIR = ".git"
from .index import Index
if not self.has_index():
- raise NoIndexPresent()
+ raise NoIndexPresent
return Index(self.index_path())
def has_index(self):
Raises:
NoIndexPresent: Raised when no index is present
"""
- raise NoIndexPresent()
+ raise NoIndexPresent
def get_config(self):
"""Retrieve the config object.
blob - e9e5ffb92a76fb7f34b19e595d7b8020781057b7
blob + 7fe34f7a969f5dca85908b43263c2c9c59f9b6c9
--- dulwich/tests/__init__.py
+++ dulwich/tests/__init__.py
def tutorial_test_suite():
- import dulwich.client
- import dulwich.config
- import dulwich.index
- import dulwich.patch # noqa: F401
-
tutorial = [
"introduction",
"file-format",
blob - 353813f4c029b63576e11ef29d626feea4370bbd
blob + cdc7dd9934035eb6c1609920e52790b253ef1efe
--- dulwich/tests/compat/test_client.py
+++ dulwich/tests/compat/test_client.py
self.assertReposEqual(src, dest)
def _client(self):
- raise NotImplementedError()
+ raise NotImplementedError
def _build_path(self):
- raise NotImplementedError()
+ raise NotImplementedError
def _do_send_pack(self):
c = self._client()
blob - c75b07f90f1117609f1545a3f81b03239c05817d
blob + 993603a9583017fdc8a19b8969b65c64a4349db1
--- dulwich/tests/compat/test_pack.py
+++ dulwich/tests/compat/test_pack.py
new_blob.data = orig_blob.data + (b"x" * 2**20)
new_blob_2 = Blob()
new_blob_2.data = new_blob.data + b"y"
- all_to_pack = [*list(orig_pack.pack_tuples()), (new_blob, None), (new_blob_2, None)]
+ all_to_pack = [
+ *list(orig_pack.pack_tuples()),
+ (new_blob, None),
+ (new_blob_2, None),
+ ]
pack_path = os.path.join(self._tempdir, "pack_with_deltas")
write_pack(pack_path, all_to_pack, deltify=True)
output = run_git_or_fail(["verify-pack", "-v", pack_path])
new_blob.data = "big blob" + ("x" * 2**25)
new_blob_2 = Blob()
new_blob_2.data = new_blob.data + "y"
- all_to_pack = [*list(orig_pack.pack_tuples()), (new_blob, None), (new_blob_2, None)]
+ all_to_pack = [
+ *list(orig_pack.pack_tuples()),
+ (new_blob, None),
+ (new_blob_2, None),
+ ]
pack_path = os.path.join(self._tempdir, "pack_with_deltas")
write_pack(pack_path, all_to_pack, deltify=True)
output = run_git_or_fail(["verify-pack", "-v", pack_path])
blob - c92e69fec98216b95cbb8965b278c9eab5cf8939
blob + 6b79de15fb60d32d08fc6e6cc321b7d6cf8c126d
--- dulwich/tests/test_client.py
+++ dulwich/tests/test_client.py
class Subprocess:
pass
- setattr(Subprocess, "read", lambda: None)
- setattr(Subprocess, "write", lambda: None)
- setattr(Subprocess, "close", lambda: None)
- setattr(Subprocess, "can_read", lambda: None)
+ Subprocess.read = lambda: None
+ Subprocess.write = lambda: None
+ Subprocess.close = lambda: None
+ Subprocess.can_read = lambda: None
return Subprocess()
binary = ["plink.exe", "-ssh"]
else:
binary = ["plink", "-ssh"]
- expected = [*binary, "-pw", "12345", "-i", "/tmp/id_rsa", "host", "git-clone-url"]
+ expected = [
+ *binary,
+ "-pw",
+ "12345",
+ "-i",
+ "/tmp/id_rsa",
+ "host",
+ "git-clone-url",
+ ]
self.assertListEqual(expected, args[0])
def test_run_command_password(self):
binary = ["plink.exe", "-ssh"]
else:
binary = ["plink", "-ssh"]
- expected = [*binary, "-P", "2200", "-i", "/tmp/id_rsa", "user@host", "git-clone-url"]
+ expected = [
+ *binary,
+ "-P",
+ "2200",
+ "-i",
+ "/tmp/id_rsa",
+ "user@host",
+ "git-clone-url",
+ ]
vendor = PLinkSSHVendor()
command = vendor.run_command(
blob - d18c3d8a9f4d4e5c77529f392098111e25ae53ac
blob + 3581f2b533b9edc65773a579d070af304d7e2705
--- dulwich/tests/test_greenthreads.py
+++ dulwich/tests/test_greenthreads.py
def init_store(store, count=1):
ret = []
- for i in range(0, count):
+ for i in range(count):
objs = create_commit(marker=("%d" % i).encode("ascii"))
for obj in objs:
ret.append(obj)
blob - 5dbae9c579b0df52c91baac1572f87152584e5f9
blob + a05ea85564e5f0fed8a0e7f2ef3919c2a7981af6
--- dulwich/tests/test_porcelain.py
+++ dulwich/tests/test_porcelain.py
# Get the change in the target repo corresponding to the add
# this will be in the foo branch.
- change = next(iter(tree_changes(
- self.repo,
- self.repo[b"HEAD"].tree,
- self.repo[b"refs/heads/foo"].tree,
- )))
+ change = next(
+ iter(
+ tree_changes(
+ self.repo,
+ self.repo[b"HEAD"].tree,
+ self.repo[b"refs/heads/foo"].tree,
+ )
+ )
+ )
self.assertEqual(
os.path.basename(fullpath), change.new.path.decode("ascii")
)
blob - cb55f4adce7f5cf3f8b5dc3e39dafd17475d5e96
blob + a2d11802a3a9e906e969f88be4d4abcdd4d703c0
--- dulwich/tests/test_repository.py
+++ dulwich/tests/test_repository.py
r.stage(['foo'])
""".format(
executable=sys.executable,
- path=[os.path.join(os.path.dirname(__file__), "..", ".."), *sys.path])
+ path=[os.path.join(os.path.dirname(__file__), "..", ".."), *sys.path],
+ )
repo_dir = os.path.join(self.mkdtemp())
self.addCleanup(shutil.rmtree, repo_dir)
blob - f285b10e53535c4a2665c7991c043e96307edbd3
blob + ccbe09029f8130ff0e94669869d831009bcbb906
--- dulwich/tests/test_server.py
+++ dulwich/tests/test_server.py
# flush-pkt ('0000').
return None
else:
- raise HangupException()
+ raise HangupException
def write_sideband(self, band, data):
self._received[band].append(data)
blob - 5791100d746a75bdecc12ab8ee485010f41a8d35
blob + 223537c9d52d9c5c4b970f0db9431e297691f3b8
--- dulwich/tests/test_web.py
+++ dulwich/tests/test_web.py
self._exc_class = exc_class
def read(self, size=-1):
- raise self._exc_class()
+ raise self._exc_class
def close(self):
self.closed = True
blob - ca9ccb5f5583008276f734539a9c8a6ae2a87368
blob + cdd235beaa8ffbfe87f4312ecd15e508341b11be
--- dulwich/tests/utils.py
+++ dulwich/tests/utils.py
import types
import warnings
-from dulwich.tests import SkipTest, skipIf # noqa: F401
+from dulwich.tests import SkipTest
from ..index import commit_tree
from ..objects import Commit, FixedSha, Tag, object_class
monkey-patched in, so this is a class that is exactly the same only
with a __dict__ instead of __slots__.
"""
-
- pass
TestObject.__name__ = "TestObject_" + cls.__name__
blob - 19da34ee7280113e6d3bc17841160119b2cb3ffe
blob + 0761416119f11745de1abc77bb48fdc5d76b6953
--- dulwich/web.py
+++ dulwich/web.py
backend: the Backend object backing this application
"""
- services: ClassVar[Dict[Tuple[str, re.Pattern], Callable[[HTTPGitRequest, Backend, re.Match], Iterator[bytes]]]] = {
+ services: ClassVar[
+ Dict[
+ Tuple[str, re.Pattern],
+ Callable[[HTTPGitRequest, Backend, re.Match], Iterator[bytes]],
+ ]
+ ] = {
("GET", re.compile("/HEAD$")): get_text_file,
("GET", re.compile("/info/refs$")): get_info_refs,
("GET", re.compile("/objects/info/alternates$")): get_text_file,
blob - 8bd3c7a729cdaa2d58a8e6f43fdc0443d3bbfff0
blob + e853ef457dfebb306b7f5db47bdb69b4a0f7b36e
--- pyproject.toml
+++ pyproject.toml
"E",
"F",
"I",
+ "PIE",
"UP",
+ "RSE",
"RUF",
]
ignore = [