Procházet zdrojové kódy

Add more missing docstrings part 4

Jelmer Vernooij před 5 měsíci
rodič
revize
1f11e954bb
5 změnil soubory, kde provedl 76 přidání a 0 odebrání
  1. 7 0
      dulwich/client.py
  2. 29 0
      dulwich/config.py
  3. 9 0
      dulwich/index.py
  4. 18 0
      dulwich/pack.py
  5. 13 0
      dulwich/refs.py

+ 7 - 0
dulwich/client.py

@@ -868,6 +868,7 @@ class GitClient:
 
         Args:
           parsedurl: Result of urlparse()
+          **kwargs: Additional keyword arguments passed to the client constructor
 
         Returns:
           A `GitClient` object
@@ -1907,6 +1908,7 @@ class LocalGitClient(GitClient):
           thin_packs: Whether or not thin packs should be retrieved
           report_activity: Optional callback for reporting transport
             activity.
+          config: Optional configuration object
         """
         self._report_activity = report_activity
         # Ignore the thin_packs argument
@@ -1958,6 +1960,8 @@ class LocalGitClient(GitClient):
             Receive dict with existing remote refs, returns dict with
             changed refs (name -> sha, where sha=ZERO_SHA for deletions)
             with number of items and pack data to upload.
+          generate_pack_data: Function that generates pack data given
+            have and want object sets
           progress: Optional progress function
 
         Returns:
@@ -2039,6 +2043,8 @@ class LocalGitClient(GitClient):
           filter_spec: A git-rev-list-style object filter spec, as bytestring.
             Only used if the server supports the Git protocol-v2 'filter'
             feature, and ignored otherwise.
+          protocol_version: Optional Git protocol version
+          **kwargs: Additional keyword arguments
 
         Returns:
           FetchPackResult object
@@ -2082,6 +2088,7 @@ class LocalGitClient(GitClient):
           filter_spec: A git-rev-list-style object filter spec, as bytestring.
             Only used if the server supports the Git protocol-v2 'filter'
             feature, and ignored otherwise.
+          protocol_version: Optional Git protocol version
 
         Returns:
           FetchPackResult object

+ 29 - 0
dulwich/config.py

@@ -426,6 +426,7 @@ class Config:
           section: Tuple with section name and optional subsection name
           name: Name of the setting, including section and possible
             subsection.
+          default: Default value if setting is not found
 
         Returns:
           Contents of the setting
@@ -572,6 +573,15 @@ class ConfigDict(Config):
         return checked_section, name
 
     def get_multivar(self, section: SectionLike, name: NameLike) -> Iterator[Value]:
+        """Get multiple values for a configuration setting.
+
+        Args:
+            section: Section name
+            name: Setting name
+
+        Returns:
+            Iterator of configuration values
+        """
         section, name = self._check_section_and_name(section, name)
 
         if len(section) > 1:
@@ -587,6 +597,18 @@ class ConfigDict(Config):
         section: SectionLike,
         name: NameLike,
     ) -> Value:
+        """Get a configuration value.
+
+        Args:
+            section: Section name
+            name: Setting name
+
+        Returns:
+            Configuration value
+
+        Raises:
+            KeyError: if the value is not set
+        """
         section, name = self._check_section_and_name(section, name)
 
         if len(section) > 1:
@@ -603,6 +625,13 @@ class ConfigDict(Config):
         name: NameLike,
         value: Union[ValueLike, bool],
     ) -> None:
+        """Set a configuration value.
+
+        Args:
+            section: Section name
+            name: Setting name
+            value: Configuration value
+        """
         section, name = self._check_section_and_name(section, name)
 
         if isinstance(value, bool):

+ 9 - 0
dulwich/index.py

@@ -722,6 +722,11 @@ class UnsupportedIndexFormat(Exception):
     """An unsupported index format was encountered."""
 
     def __init__(self, version: int) -> None:
+        """Initialize UnsupportedIndexFormat exception.
+
+        Args:
+            version: The unsupported index format version
+        """
         self.index_format_version = version
 
 
@@ -997,6 +1002,7 @@ class Index:
         return self._filename
 
     def __repr__(self) -> str:
+        """Return string representation of Index."""
         return f"{self.__class__.__name__}({self._filename!r})"
 
     def write(self) -> None:
@@ -1072,6 +1078,7 @@ class Index:
         return iter(self._byname)
 
     def __contains__(self, key: bytes) -> bool:
+        """Check if a path exists in the index."""
         return key in self._byname
 
     def get_sha1(self, path: bytes) -> bytes:
@@ -1114,10 +1121,12 @@ class Index:
     def __setitem__(
         self, name: bytes, value: Union[IndexEntry, ConflictedIndexEntry]
     ) -> None:
+        """Set an entry in the index."""
         assert isinstance(name, bytes)
         self._byname[name] = value
 
     def __delitem__(self, name: bytes) -> None:
+        """Delete an entry from the index."""
         del self._byname[name]
 
     def iteritems(

+ 18 - 0
dulwich/pack.py

@@ -1816,6 +1816,12 @@ class DeltaChainIterator(Generic[T]):
     _include_comp = False
 
     def __init__(self, file_obj, *, resolve_ext_ref=None) -> None:
+        """Initialize DeltaChainIterator.
+
+        Args:
+            file_obj: File object to read pack data from
+            resolve_ext_ref: Optional function to resolve external references
+        """
         self._file = file_obj
         self._resolve_ext_ref = resolve_ext_ref
         self._pending_ofs: dict[int, list[int]] = defaultdict(list)
@@ -1993,6 +1999,7 @@ class DeltaChainIterator(Generic[T]):
             )
 
     def __iter__(self) -> Iterator[T]:
+        """Iterate over objects in the pack."""
         return self._walk_all_chains()
 
     def ext_refs(self):
@@ -2785,6 +2792,15 @@ class PackChunkGenerator:
         compression_level=-1,
         reuse_compressed=True,
     ) -> None:
+        """Initialize PackChunkGenerator.
+
+        Args:
+            num_records: Expected number of records
+            records: Iterator of pack records
+            progress: Optional progress callback
+            compression_level: Compression level (-1 for default)
+            reuse_compressed: Whether to reuse compressed chunks
+        """
         self.cs = sha1(b"")
         self.entries: dict[Union[int, bytes], tuple[int, int]] = {}
         self._it = self._pack_data_chunks(
@@ -2796,9 +2812,11 @@ class PackChunkGenerator:
         )
 
     def sha1digest(self):
+        """Return the SHA1 digest of the pack data."""
         return self.cs.digest()
 
     def __iter__(self):
+        """Iterate over pack data chunks."""
         return self._it
 
     def _pack_data_chunks(

+ 13 - 0
dulwich/refs.py

@@ -180,6 +180,9 @@ class RefsContainer:
         Args:
           name: Name of the ref to set
           other: Name of the ref to point at
+          committer: Optional committer name/email
+          timestamp: Optional timestamp
+          timezone: Optional timezone
           message: Optional message
         """
         raise NotImplementedError(self.set_symbolic_ref)
@@ -412,6 +415,9 @@ class RefsContainer:
           old_ref: The old sha the refname must refer to, or None to set
             unconditionally.
           new_ref: The new sha the refname will refer to.
+          committer: Optional committer name/email
+          timestamp: Optional timestamp
+          timezone: Optional timezone
           message: Message for reflog
         Returns: True if the set was successful, False otherwise.
         """
@@ -425,6 +431,10 @@ class RefsContainer:
         Args:
           name: Ref name
           ref: Ref value
+          committer: Optional committer name/email
+          timestamp: Optional timestamp
+          timezone: Optional timezone
+          message: Optional message for reflog
         """
         raise NotImplementedError(self.add_if_new)
 
@@ -465,6 +475,9 @@ class RefsContainer:
           name: The refname to delete.
           old_ref: The old sha the refname must refer to, or None to
             delete unconditionally.
+          committer: Optional committer name/email
+          timestamp: Optional timestamp
+          timezone: Optional timezone
           message: Message for reflog
         Returns: True if the delete was successful, False otherwise.
         """