Skip to content

Revise comments, docstrings, some messages, and a bit of code #1725

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

Merged
merged 36 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7dd2095
Fix docstrings that intend '\' literally
EliahKagan Oct 10, 2023
ffcbf07
Put all regex patterns in r-strings
EliahKagan Oct 10, 2023
2c94b6a
Remove r prefix from strings that need not be raw
EliahKagan Oct 10, 2023
35fd65b
Fix _index_from_*_format docstrings (proc reading)
EliahKagan Oct 15, 2023
5af7446
Fix case in IndexObject.abspath exception message
EliahKagan Oct 16, 2023
692e59e
Remove Commit._deserialize doc for param_from_rev_list
EliahKagan Oct 16, 2023
ab46192
Add missing space in Submodule.update debug message
EliahKagan Oct 17, 2023
1114828
Remove obsolete comment in Submodule.module
EliahKagan Oct 18, 2023
f95d4fd
Clarify "master repository" in RootModule docs
EliahKagan Oct 18, 2023
9fea488
Change spelling from "commit'ish" to "commit-ish"
EliahKagan Oct 18, 2023
4536b63
Update git-source citation in Reference.set_object
EliahKagan Oct 18, 2023
59d208c
Fix message in SymbolicReference.from_path
EliahKagan Oct 18, 2023
add46d9
Use "is" to compare __class__
EliahKagan Oct 18, 2023
cd16a35
Revise docstrings and comments for clarity and formatting
EliahKagan Oct 18, 2023
e8343e2
Firm up comment about is_win in util.is_cygwin_git
EliahKagan Oct 18, 2023
f78587f
Remove explicit inheritance from object
EliahKagan Oct 18, 2023
0327f8f
Make all one-element __slots__ be tuples
EliahKagan Oct 18, 2023
d4a87c1
Revise comments in tests used to generate tutorials
EliahKagan Oct 22, 2023
11fce8a
Revise docstrings/comments in most other test modules
EliahKagan Oct 20, 2023
cf9243a
Add a module docstring to tstrunner.py
EliahKagan Oct 23, 2023
b5c3ca4
Slightly improve readability of installation-test strings
EliahKagan Oct 23, 2023
f444470
More wording improvements (in git module)
EliahKagan Oct 23, 2023
db317f1
Change :returns: to :return:
EliahKagan Oct 23, 2023
720e4bb
Fix TestBigRepoR.setUp info message
EliahKagan Oct 23, 2023
faa19ac
Remove outdated git_daemon_launched Windows info
EliahKagan Oct 24, 2023
bffc537
Revise docstrings/comments in test helpers
EliahKagan Oct 24, 2023
30f49d9
Revise docstrings/comments in performance tests
EliahKagan Oct 24, 2023
8d3efc5
Remove explicit inheritance from object in test suite
EliahKagan Oct 24, 2023
a5fc1d8
Improve consistency of "END" comments
EliahKagan Oct 24, 2023
c2eb6b5
Add missing comment revisions in git/objects/submodule/base.py
EliahKagan Oct 24, 2023
ddb4417
Improve consistency of "END" comments in test suite
EliahKagan Oct 24, 2023
1d3f275
Avoid making "END" notation more verbose
EliahKagan Oct 30, 2023
81dad7e
Add missing comment revisions in git/index/base.py
EliahKagan Oct 30, 2023
a040edb
Shorten some docstring references with tilde notation
EliahKagan Oct 30, 2023
af1b5d4
Fix commented *.py names at the top of modules
EliahKagan Oct 30, 2023
b970d42
Remove encoding declarations
EliahKagan Oct 30, 2023
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
Next Next commit
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.
  • Loading branch information
EliahKagan committed Oct 22, 2023
commit cd16a3534eedb5a0990293e16a6371ca16d8776a
2 changes: 2 additions & 0 deletions git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#
# This module is part of GitPython and is released under
# the BSD License: https://opensource.org/license/bsd-3-clause/

# flake8: noqa
# @PydevCodeAnalysisIgnore

from git.exc import * # @NoMove @IgnorePep8
from typing import List, Optional, Sequence, Tuple, Union, TYPE_CHECKING
from git.types import PathLike
Expand Down
357 changes: 184 additions & 173 deletions git/cmd.py

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions git/compat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
# config.py
# compat.py
# Copyright (C) 2008, 2009 Michael Trier ([email protected]) and contributors
#
# This module is part of GitPython and is released under
# the BSD License: https://opensource.org/license/bsd-3-clause/
"""utilities to help provide compatibility with python 3"""

"""Utilities to help provide compatibility with Python 3."""

# flake8: noqa

import locale
Expand Down Expand Up @@ -50,7 +52,7 @@ def safe_decode(s: AnyStr) -> str:


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


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


def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
"""Encode unicodes for process arguments on Windows."""
"""Encode Unicode strings for process arguments on Windows."""
if isinstance(s, str):
return s.encode(locale.getpreferredencoding(False))
elif isinstance(s, bytes):
Expand Down
225 changes: 122 additions & 103 deletions git/config.py

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions git/db.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module with our own gitdb implementation - it uses the git command"""
"""Module with our own gitdb implementation - it uses the git command."""

from git.util import bin_to_hex, hex_to_bin
from gitdb.base import OInfo, OStream
from gitdb.db import GitDB
Expand All @@ -22,17 +23,17 @@


class GitCmdObjectDB(LooseObjectDB):

"""A database representing the default git object store, which includes loose
objects, pack files and an alternates file
objects, pack files and an alternates file.

It will create objects only in the loose object database.
:note: for now, we use the git command to do all the lookup, just until he
have packs and the other implementations

:note: For now, we use the git command to do all the lookup, just until we
have packs and the other implementations.
"""

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

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

def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
""":return: Full binary 20 byte sha from the given partial hexsha
"""
:return: Full binary 20 byte sha from the given partial hexsha

:raise AmbiguousObjectName:
:raise BadObject:
:note: currently we only raise BadObject as git does not communicate
AmbiguousObjects separately"""

:note: Currently we only raise :class:`BadObject` as git does not communicate
AmbiguousObjects separately.
"""
try:
hexsha, _typename, _size = self._git.get_object_header(partial_hexsha)
return hex_to_bin(hexsha)
Expand Down
Loading