Explorar o código

Add missing type hints to bitmap functions

Jelmer Vernooij hai 2 meses
pai
achega
a56449388c
Modificáronse 2 ficheiros con 9 adicións e 13 borrados
  1. 2 4
      dulwich/bitmap.py
  2. 7 9
      dulwich/object_store.py

+ 2 - 4
dulwich/bitmap.py

@@ -33,7 +33,7 @@ import struct
 from collections import deque
 from collections.abc import Callable, Iterable, Iterator
 from io import BytesIO
-from typing import IO, TYPE_CHECKING, Optional
+from typing import IO, TYPE_CHECKING, Callable, Optional
 
 from .file import GitFile
 from .objects import Blob, Commit, Tag, Tree
@@ -1143,9 +1143,7 @@ def generate_bitmap(
     return pack_bitmap
 
 
-def find_commit_bitmaps(
-    commit_shas: set[bytes], packs: Iterable[Pack]
-) -> dict[bytes, tuple]:
+def find_commit_bitmaps(commit_shas: set[bytes], packs: Iterable[Pack]) -> dict[bytes, tuple]:
     """Find which packs have bitmaps for the given commits.
 
     Args:

+ 7 - 9
dulwich/object_store.py

@@ -83,9 +83,11 @@ from .protocol import DEPTH_INFINITE
 from .refs import PEELED_TAG_SUFFIX, Ref
 
 if TYPE_CHECKING:
+    from .bitmap import EWAHBitmap
     from .commit_graph import CommitGraph
     from .config import Config
     from .diff_tree import RenameDetector
+    from .pack import Pack
 
 
 class GraphWalker(Protocol):
@@ -823,14 +825,10 @@ class PackBasedObjectStore(PackCapableObjectStore, PackedObjectContainer):
             # Check if any packs have bitmaps
             has_bitmap = False
             for pack in self.packs:
-                try:
-                    # Try to access bitmap property
-                    if pack.bitmap is not None:
-                        has_bitmap = True
-                        break
-                except (FileNotFoundError, ValueError, AttributeError):
-                    # No bitmap file, corrupt bitmap, or no bitmap support
-                    continue
+                # Try to access bitmap property
+                if pack.bitmap is not None:
+                    has_bitmap = True
+                    break
 
             if has_bitmap:
                 return BitmapReachability(self)
@@ -3259,7 +3257,7 @@ class BitmapReachability:
         self,
         commit_shas: set[bytes],
         exclude_shas: set[bytes] | None = None,
-    ) -> tuple | None:
+    ) -> tuple["EWAHBitmap", "Pack"] | None:
         """Combine bitmaps for multiple commits using OR, with optional exclusion.
 
         Args: