Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more type annotations #1446

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix test failures
  • Loading branch information
jelmer committed Nov 20, 2024
commit 3878e14307160c005da7df0f36fe76cd80eea322
21 changes: 6 additions & 15 deletions dulwich/tests/test_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

"""Tests for the object store interface."""

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable
from unittest import skipUnless

from dulwich.index import commit_tree
Expand Down Expand Up @@ -53,20 +53,11 @@
class ObjectStoreTests:
store: "BaseObjectStore"

def assertEqual(self, a, b) -> None:
raise NotImplementedError

def assertRaises(self, exc, func) -> None:
raise NotImplementedError

def assertNotIn(self, a, b) -> None:
raise NotImplementedError

def assertNotEqual(self, a, b) -> None:
raise NotImplementedError

def assertIn(self, a, b) -> None:
raise NotImplementedError
assertEqual: Callable[[object, object], None]
assertRaises: Callable[[type[Exception], Callable[[], Any]], None]
assertNotIn: Callable[[object, object], None]
assertNotEqual: Callable[[object, object], None]
assertIn: Callable[[object, object], None]

def test_determine_wants_all(self) -> None:
self.assertEqual(
Expand Down
9 changes: 5 additions & 4 deletions tests/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,8 +1295,6 @@ def test_bad_ext_ref_thin_pack(self) -> None:
self.assertEqual((sorted([b2.id, b3.id]),), (sorted(e.shas),))

def test_ext_ref_deltified_object_based_on_itself(self) -> None:
td = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, td)
b1_content = b"foo"
(b1,) = self.store_blobs([b1_content])
f = BytesIO()
Expand All @@ -1311,12 +1309,15 @@ def test_ext_ref_deltified_object_based_on_itself(self) -> None:
fsize = f.tell()
f.seek(0)
packdata = PackData.from_file(f, fsize)
td = tempfile.mkdtemp()
idx_path = os.path.join(td, "test.idx")
self.addCleanup(shutil.rmtree, td)
packdata.create_index(
td.join("test.idx"),
idx_path,
version=2,
resolve_ext_ref=self.get_raw_no_repeat,
)
packindex = load_pack_index(td.join("test.idx"))
packindex = load_pack_index(idx_path)
pack = Pack.from_objects(packdata, packindex)
try:
# Attempting to open this REF_DELTA object would loop forever
Expand Down
Loading