Skip to content

Commit cd16a35

Browse files
committed
Revise docstrings and comments for clarity and formatting
In the git module (including the modules it contains). This also makes one small change in doc/ to synchronize with a change made in a docstring.
1 parent add46d9 commit cd16a35

37 files changed

+2370
-1892
lines changed

git/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#
44
# This module is part of GitPython and is released under
55
# the BSD License: https://opensource.org/license/bsd-3-clause/
6+
67
# flake8: noqa
78
# @PydevCodeAnalysisIgnore
9+
810
from git.exc import * # @NoMove @IgnorePep8
911
from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
1012
from git.types import PathLike

git/cmd.py

+184-173
Large diffs are not rendered by default.

git/compat.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
# config.py
2+
# compat.py
33
# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors
44
#
55
# This module is part of GitPython and is released under
66
# the BSD License: https://opensource.org/license/bsd-3-clause/
7-
"""utilities to help provide compatibility with python 3"""
7+
8+
"""Utilities to help provide compatibility with Python 3."""
9+
810
# flake8: noqa
911

1012
import locale
@@ -50,7 +52,7 @@ def safe_decode(s: AnyStr) -> str:
5052

5153

5254
def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:
53-
"""Safely decodes a binary string to unicode"""
55+
"""Safely decode a binary string to Unicode."""
5456
if isinstance(s, str):
5557
return s
5658
elif isinstance(s, bytes):
@@ -72,7 +74,7 @@ def safe_encode(s: AnyStr) -> bytes:
7274

7375

7476
def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
75-
"""Safely encodes a binary string to unicode"""
77+
"""Safely encode a binary string to Unicode."""
7678
if isinstance(s, str):
7779
return s.encode(defenc)
7880
elif isinstance(s, bytes):
@@ -94,7 +96,7 @@ def win_encode(s: AnyStr) -> bytes:
9496

9597

9698
def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
97-
"""Encode unicodes for process arguments on Windows."""
99+
"""Encode Unicode strings for process arguments on Windows."""
98100
if isinstance(s, str):
99101
return s.encode(locale.getpreferredencoding(False))
100102
elif isinstance(s, bytes):

git/config.py

+122-103
Large diffs are not rendered by default.

git/db.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"""Module with our own gitdb implementation - it uses the git command"""
1+
"""Module with our own gitdb implementation - it uses the git command."""
2+
23
from git.util import bin_to_hex, hex_to_bin
34
from gitdb.base import OInfo, OStream
45
from gitdb.db import GitDB
@@ -22,17 +23,17 @@
2223

2324

2425
class GitCmdObjectDB(LooseObjectDB):
25-
2626
"""A database representing the default git object store, which includes loose
27-
objects, pack files and an alternates file
27+
objects, pack files and an alternates file.
2828
2929
It will create objects only in the loose object database.
30-
:note: for now, we use the git command to do all the lookup, just until he
31-
have packs and the other implementations
30+
31+
:note: For now, we use the git command to do all the lookup, just until we
32+
have packs and the other implementations.
3233
"""
3334

3435
def __init__(self, root_path: PathLike, git: "Git") -> None:
35-
"""Initialize this instance with the root and a git command"""
36+
"""Initialize this instance with the root and a git command."""
3637
super(GitCmdObjectDB, self).__init__(root_path)
3738
self._git = git
3839

@@ -48,11 +49,15 @@ def stream(self, binsha: bytes) -> OStream:
4849
# { Interface
4950

5051
def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
51-
""":return: Full binary 20 byte sha from the given partial hexsha
52+
"""
53+
:return: Full binary 20 byte sha from the given partial hexsha
54+
5255
:raise AmbiguousObjectName:
5356
:raise BadObject:
54-
:note: currently we only raise BadObject as git does not communicate
55-
AmbiguousObjects separately"""
57+
58+
:note: Currently we only raise :class:`BadObject` as git does not communicate
59+
AmbiguousObjects separately.
60+
"""
5661
try:
5762
hexsha, _typename, _size = self._git.get_object_header(partial_hexsha)
5863
return hex_to_bin(hexsha)

0 commit comments

Comments
 (0)