Jelmer Vernooij 1 lună în urmă
părinte
comite
4cb1efdab6
3 a modificat fișierele cu 41 adăugiri și 4 ștergeri
  1. 13 0
      dulwich/config.py
  2. 3 3
      dulwich/object_store.py
  3. 25 1
      dulwich/pack.py

+ 13 - 0
dulwich/config.py

@@ -709,6 +709,19 @@ class ConfigDict(Config):
 
         self._values.setdefault(section)[name] = value
 
+    def remove(self, section: SectionLike, name: NameLike) -> None:
+        """Remove a configuration setting.
+
+        Args:
+            section: Section name
+            name: Setting name
+
+        Raises:
+            KeyError: If the section or name doesn't exist
+        """
+        section, name = self._check_section_and_name(section, name)
+        del self._values[section][name]
+
     def items(self, section: SectionLike) -> Iterator[tuple[Name, Value]]:
         """Get items in a section."""
         section_bytes, _ = self._check_section_and_name(section, b"")

+ 3 - 3
dulwich/object_store.py

@@ -2606,8 +2606,8 @@ class MemoryObjectStore(PackCapableObjectStore):
 
     def add_thin_pack(
         self,
-        read_all: Callable[[], bytes],
-        read_some: Callable[[int], bytes],
+        read_all: Callable[[int], bytes],
+        read_some: Callable[[int], bytes] | None,
         progress: Callable[[str], None] | None = None,
     ) -> None:
         """Add a new thin pack to this object store.
@@ -2629,7 +2629,7 @@ class MemoryObjectStore(PackCapableObjectStore):
                 self.object_format.hash_func,
                 read_all,
                 read_some,
-                f,  # type: ignore[arg-type]
+                f,
             )
             copier.verify()
         except BaseException:

+ 25 - 1
dulwich/pack.py

@@ -2658,6 +2658,18 @@ class SHA1Writer(BinaryIO):
         """Exit context manager and close file."""
         self.f.close()
 
+    def __iter__(self) -> "SHA1Writer":
+        """Return iterator."""
+        return self
+
+    def __next__(self) -> bytes:
+        """Not supported for write-only file.
+
+        Raises:
+            UnsupportedOperation: Always raised
+        """
+        raise UnsupportedOperation("__next__")
+
     def fileno(self) -> int:
         """Return file descriptor number."""
         return self.f.fileno()
@@ -2813,6 +2825,18 @@ class HashWriter(BinaryIO):
         """Exit context manager and close file."""
         self.close()
 
+    def __iter__(self) -> "HashWriter":
+        """Return iterator."""
+        return self
+
+    def __next__(self) -> bytes:
+        """Not supported for write-only file.
+
+        Raises:
+            UnsupportedOperation: Always raised
+        """
+        raise UnsupportedOperation("__next__")
+
     def fileno(self) -> int:
         """Return file descriptor number."""
         return self.f.fileno()
@@ -3754,7 +3778,7 @@ def write_pack_index_v2(
     else:
         raise ValueError(f"Unsupported pack checksum length: {len(pack_checksum)}")
 
-    f_writer = HashWriter(f, hash_func)  # type: ignore[abstract]
+    f_writer = HashWriter(f, hash_func)
     f_writer.write(b"\377tOc")  # Magic!
     f_writer.write(struct.pack(">L", 2))