Skip to content

Commit

Permalink
Format source code, and enforce with github action (jelmer#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer authored May 14, 2024
2 parents 9d13065 + 9315f2c commit c7bf165
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pythontest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
run: |
pip install --upgrade ruff
python -m ruff check .
python -m ruff format --check .
- name: Typing checks
run: |
pip install --upgrade mypy types-paramiko types-requests
Expand Down
4 changes: 3 additions & 1 deletion dulwich/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ class SuperCommand(Command):

def run(self, args):
if not args and not self.default_command:
print("Supported subcommands: {}".format(", ".join(self.subcommands.keys())))
print(
"Supported subcommands: {}".format(", ".join(self.subcommands.keys()))
)
return False
cmd = args[0]
try:
Expand Down
6 changes: 5 additions & 1 deletion dulwich/diff_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ def _all_same(seq, key):


def tree_changes_for_merge(
store: BaseObjectStore, parent_tree_ids: List[ObjectID], tree_id: ObjectID, rename_detector=None):
store: BaseObjectStore,
parent_tree_ids: List[ObjectID],
tree_id: ObjectID,
rename_detector=None,
):
"""Get the tree changes for a merge tree relative to all its parents.
Args:
Expand Down
8 changes: 2 additions & 6 deletions dulwich/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,7 @@ def __getitem__(self, name: Union[ObjectID, Ref]):
KeyError: when the specified ref or object does not exist
"""
if not isinstance(name, bytes):
raise TypeError(
f"'name' must be bytestring, not {type(name).__name__:.80}"
)
raise TypeError(f"'name' must be bytestring, not {type(name).__name__:.80}")
if len(name) in (20, 40):
try:
return self.object_store[name]
Expand Down Expand Up @@ -1473,9 +1471,7 @@ def unstage(self, fs_paths: List[str]):
del index[tree_path]
continue
except KeyError as exc:
raise KeyError(
f"file '{tree_path.decode()}' not in index"
) from exc
raise KeyError(f"file '{tree_path.decode()}' not in index") from exc

st = None
try:
Expand Down
3 changes: 0 additions & 3 deletions dulwich/tests/test_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,3 @@ def test_repack_existing(self):
self.assertEqual(2, self.store.repack())
self.assertEqual(1, len(self.store.packs))
self.assertEqual(0, self.store.pack_loose_objects())



4 changes: 1 addition & 3 deletions tests/compat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
_DEFAULT_GIT = "git"
_VERSION_LEN = 4
_REPOS_DATA_DIR = os.path.abspath(
os.path.join(
os.path.dirname(__file__), os.pardir, os.pardir, "testdata", "repos"
)
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "testdata", "repos")
)


Expand Down
1 change: 1 addition & 0 deletions tests/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# License, Version 2.0.
#


def test_suite():
import unittest

Expand Down
4 changes: 1 addition & 3 deletions tests/contrib/test_swift_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ def determine_wants(*args, **kwargs):
)
swift_repo = swift.SwiftRepo("fakerepo", self.conf)
for branch in ("master", "mybranch", "pullr-108"):
remote_shas[branch] = swift_repo.refs.read_loose_ref(
f"refs/heads/{branch}"
)
remote_shas[branch] = swift_repo.refs.read_loose_ref(f"refs/heads/{branch}")
self.assertDictEqual(local_shas, remote_shas)

def test_push_data_branch(self):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,9 +1207,7 @@ def request(
preload_content=True,
):
response = HTTPResponse(
headers={
"Content-Type": "application/x-git-upload-pack-result"
},
headers={"Content-Type": "application/x-git-upload-pack-result"},
request_method=method,
request_url=url,
preload_content=preload_content,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ def test_create_pack(self):
self.get_pack_data(pack1_sha).close()

def test_from_file(self):
path = os.path.join(self.datadir, "pack-{}.pack".format(pack1_sha.decode("ascii")))
path = os.path.join(
self.datadir, "pack-{}.pack".format(pack1_sha.decode("ascii"))
)
with open(path, "rb") as f:
PackData.from_file(f, os.path.getsize(path))

Expand Down
4 changes: 1 addition & 3 deletions tests/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ def test_extract_mercurial(self):
class DiffTests(TestCase):
"""
text = (
f"""\
text = f"""\
From [email protected] \
Mon Nov 29 00:58:18 2010
Date: Sun, 28 Nov 2010 17:57:27 -0600
Expand All @@ -255,7 +254,6 @@ class DiffTests(TestCase):
More help : https://help.launchpad.net/ListHelp
"""
)
c, diff, version = git_am_patch_split(BytesIO(text))
self.assertEqual(expected_diff, diff)
self.assertEqual(None, version)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ def test_clone(self):
def test_clone_no_head(self):
temp_dir = self.mkdtemp()
self.addCleanup(shutil.rmtree, temp_dir)
repo_dir = os.path.join(
os.path.dirname(__file__), "..", "testdata", "repos"
)
repo_dir = os.path.join(os.path.dirname(__file__), "..", "testdata", "repos")
dest_dir = os.path.join(temp_dir, "a.git")
shutil.copytree(os.path.join(repo_dir, "a.git"), dest_dir, symlinks=True)
r = Repo(dest_dir)
Expand Down

0 comments on commit c7bf165

Please sign in to comment.