Skip to content

Revise docstrings, comments, and a few messages #1850

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 61 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9b5531b
Fix typos and further clarify Git.refresh docstring
EliahKagan Feb 24, 2024
c0cd8a8
Clarify comment on shell case in _safer_popen_windows
EliahKagan Feb 24, 2024
afd943a
Tweak message about GIT_PYTHON_REFRESH for 80-column terminals
EliahKagan Feb 24, 2024
e08066c
Revise docstrings in git.__init__ and git.cmd
EliahKagan Feb 24, 2024
8bb882e
Fix concurrency note for stream_object_data
EliahKagan Feb 24, 2024
ba878ef
Reword partial_to_complete_sha_hex note
EliahKagan Feb 24, 2024
3958747
Update CommandError._msg documentation
EliahKagan Feb 24, 2024
f56e1ac
Tweak code formatting in Remote._set_cache_
EliahKagan Feb 24, 2024
fa471fe
Fix up Remote.push docstring
EliahKagan Feb 24, 2024
1cd73ba
Revise docstrings in second-level modules
EliahKagan Feb 25, 2024
29c63ac
Format first Git.execute overload stub like the others
EliahKagan Feb 25, 2024
cd8a312
Show full-path refresh() in failure message differently
EliahKagan Feb 25, 2024
8ec7e32
Revise docstrings within git.index
EliahKagan Feb 26, 2024
ca2ab61
Rewrite post_clear_cache note
EliahKagan Feb 26, 2024
37421e1
Further revise post_clear_cache docstring
EliahKagan Feb 26, 2024
ca32c22
Condense output_stream description in Git.execute docstring
EliahKagan Feb 26, 2024
3813bfb
Clarify Submodule.branch_path documentation
EliahKagan Feb 26, 2024
63c62ed
Revise docstrings within git.objects.submodule
EliahKagan Feb 27, 2024
115451d
Change _write to write in SubmoduleConfigParser docstring
EliahKagan Feb 27, 2024
5219489
Fix IndexObject.abspath docstring formatting
EliahKagan Feb 27, 2024
c06dfd9
Fix parameter names in TagObject.__init__
EliahKagan Feb 27, 2024
ae37a4a
Revise docstrings within git.objects
EliahKagan Feb 27, 2024
37011bf
Fix backslash formatting in git.util docstrings
EliahKagan Feb 27, 2024
d9fb2f4
Further git.util docstring revisions
EliahKagan Feb 27, 2024
d1d18c2
Revise docstrings within git.refs
EliahKagan Feb 27, 2024
4f67369
Fix backslashes in Repo.__init__ docstring
EliahKagan Feb 27, 2024
0c8ca1a
Fix Repo.iter_commits docstring about return type
EliahKagan Feb 27, 2024
b2b6f7c
Revise docstrings within git.repo
EliahKagan Feb 28, 2024
c67b2e2
Adjust spacing in colon seach mode NotImplementedError
EliahKagan Feb 28, 2024
5ee8744
Update git source link in Repo.merge_base comment
EliahKagan Feb 28, 2024
c8b6cf0
Update comment about improving expand_path overloads
EliahKagan Feb 28, 2024
bcc0c27
Fix recent inconsistency, using :raise:, not :raises:
EliahKagan Feb 28, 2024
0231b74
Further revise docstrings in git.objects.submodule.base
EliahKagan Feb 28, 2024
8344f44
Revise Repo.archive docstring
EliahKagan Feb 28, 2024
432ec72
Fix another :raises: to :raise:
EliahKagan Feb 28, 2024
5ca5844
Fully qualify non-builtin exceptions in :raise:
EliahKagan Feb 28, 2024
e6768ec
Improve Git.execute docstring formatting re: max_chunk_size
EliahKagan Feb 28, 2024
cd61eb4
Further revise docstrings in second-level modules
EliahKagan Feb 28, 2024
fc1762b
Undo a couple minor black-incompatible changes
EliahKagan Feb 28, 2024
1b25a13
Further revise docstrings within git.index
EliahKagan Feb 28, 2024
08a80aa
Further revise docstrings within git.objects.submodule
EliahKagan Feb 28, 2024
bc48d26
Further revise other docstrings within git.objects
EliahKagan Feb 28, 2024
30f7da5
Fix erroneous reference to DateTime "class"
EliahKagan Feb 28, 2024
6126997
Improve docstrings about tags
EliahKagan Feb 29, 2024
110706e
Fix param name in TagRefernece docstring and add info
EliahKagan Feb 29, 2024
b0e5bff
Undo some expansion of "reference" parameter
EliahKagan Feb 29, 2024
a5a1b2c
Add a bit of missing docstring formatting
EliahKagan Feb 29, 2024
018ebaf
Further revise docstrings within git.repo
EliahKagan Feb 29, 2024
608147e
Better explain conditional cleanup in test_base_object
EliahKagan Feb 29, 2024
5cf5b60
Revise test suite docstrings and comments
EliahKagan Feb 29, 2024
4b04d8a
Better clarify Submodule.branch_path documentation
EliahKagan Feb 29, 2024
254c82a
More docstring revisions within git.refs
EliahKagan Feb 29, 2024
679d2e8
Fix exception type in require_remote_ref_path docstring
EliahKagan Feb 29, 2024
ee0301a
More docstring revisions in second-level modules and git.__init__
EliahKagan Feb 29, 2024
231c3ef
More docstring revisions within git.repo
EliahKagan Feb 29, 2024
e166a0a
More docstring revisions within git.objects
EliahKagan Feb 29, 2024
ffeb7e7
More docstring revisions in git.objects.submodule.base
EliahKagan Feb 29, 2024
ec93955
Further refine some docstring revisions
EliahKagan Feb 29, 2024
63983c2
Remove note in GitCmdObjectDB docstring
EliahKagan Feb 29, 2024
f43292e
Somewhat improve _get_ref_info{,_helper} docstrings
EliahKagan Feb 29, 2024
37c93de
A couple more small docstring refinements
EliahKagan Feb 29, 2024
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
More docstring revisions within git.refs
  • Loading branch information
EliahKagan committed Feb 29, 2024
commit 254c82a00a3a6d141cfb6df7fdb8f33a23d4ebcb
32 changes: 16 additions & 16 deletions git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def strip_quotes(string: str) -> str:


class HEAD(SymbolicReference):
"""Special case of a SymbolicReference representing the repository's
HEAD reference."""
"""Special case of a SymbolicReference representing the repository's HEAD
reference."""

_HEAD_NAME = "HEAD"
_ORIG_HEAD_NAME = "ORIG_HEAD"
Expand Down Expand Up @@ -66,22 +66,21 @@ def reset(
paths: Union[PathLike, Sequence[PathLike], None] = None,
**kwargs: Any,
) -> "HEAD":
"""Reset our HEAD to the given commit optionally synchronizing
the index and working tree. The reference we refer to will be set to commit as
well.
"""Reset our HEAD to the given commit optionally synchronizing the index and
working tree. The reference we refer to will be set to commit as well.

:param commit:
:class:`~git.objects.commit.Commit`, :class:`~git.refs.reference.Reference`,
or string identifying a revision we should reset HEAD to.

:param index:
If True, the index will be set to match the given commit.
If ``True``, the index will be set to match the given commit.
Otherwise it will not be touched.

:param working_tree:
If True, the working tree will be forcefully adjusted to match the given
If ``True``, the working tree will be forcefully adjusted to match the given
commit, possibly overwriting uncommitted changes without warning.
If `working_tree` is True, `index` must be True as well.
If `working_tree` is ``True``, `index` must be ``True`` as well.

:param paths:
Single path or list of paths relative to the git root directory
Expand All @@ -90,7 +89,8 @@ def reset(
:param kwargs:
Additional arguments passed to ``git reset``.

:return: self
:return:
self
"""
mode: Union[str, None]
mode = "--soft"
Expand Down Expand Up @@ -151,8 +151,8 @@ def delete(cls, repo: "Repo", *heads: "Union[Head, str]", force: bool = False, *
"""Delete the given heads.

:param force:
If True, the heads will be deleted even if they are not yet merged into the
main development stream. Default False.
If ``True``, the heads will be deleted even if they are not yet merged into
the main development stream. Default ``False``.
"""
flag = "-d"
if force:
Expand Down Expand Up @@ -193,7 +193,7 @@ def set_tracking_branch(self, remote_reference: Union["RemoteReference", None])
def tracking_branch(self) -> Union["RemoteReference", None]:
"""
:return:
The remote reference we are tracking, or None if we are not a tracking
The remote reference we are tracking, or ``None`` if we are not a tracking
branch.
"""
from .remote import RemoteReference
Expand All @@ -219,14 +219,14 @@ def rename(self, new_path: PathLike, force: bool = False) -> "Head":
The prefix ``refs/heads`` is implied.

:param force:
If True, the rename will succeed even if a head with the target name
If ``True``, the rename will succeed even if a head with the target name
already exists.

:return:
self

:note:
Respects the ref log as git commands are used.
Respects the ref log, as git commands are used.
"""
flag = "-m"
if force:
Expand All @@ -244,8 +244,8 @@ def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]:
The command will fail if changed working tree files would be overwritten.

:param force:
If True, changes to the index and the working tree will be discarded.
If False, :class:`~git.exc.GitCommandError` will be raised in that
If ``True``, changes to the index and the working tree will be discarded.
If ``False``, :class:`~git.exc.GitCommandError` will be raised in that
situation.

:param kwargs:
Expand Down
8 changes: 4 additions & 4 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ def new(
tz_offset: int,
message: str,
) -> "RefLogEntry": # skipcq: PYL-W0621
""":return: New instance of a RefLogEntry"""
""":return: New instance of a :class:`RefLogEntry`"""
if not isinstance(actor, Actor):
raise ValueError("Need actor instance, got %s" % actor)
# END check types
return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), message))

@classmethod
def from_line(cls, line: bytes) -> "RefLogEntry":
""":return: New RefLogEntry instance from the given revlog line.
""":return: New :class:`RefLogEntry` instance from the given revlog line.

:param line:
Line bytes without trailing newline
Expand Down Expand Up @@ -311,7 +311,7 @@ def append_entry(
:param config_reader:
Configuration reader of the repository - used to obtain user information.
May also be an :class:`~git.util.Actor` instance identifying the committer
directly or None.
directly or ``None``.

:param filepath:
Full path to the log file.
Expand All @@ -326,7 +326,7 @@ def append_entry(
Message describing the change to the reference.

:param write:
If True, the changes will be written right away.
If ``True``, the changes will be written right away.
Otherwise the change will not be written.

:return:
Expand Down
7 changes: 4 additions & 3 deletions git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, repo: "Repo", path: PathLike, check_path: bool = True) -> Non
e.g. ``refs/heads/master``.

:param check_path:
If False, you can provide any path.
If ``False``, you can provide any path.
Otherwise the path must start with the default path prefix of this type.
"""
if check_path and not str(path).startswith(self._common_path_default + "/"):
Expand Down Expand Up @@ -141,8 +141,9 @@ def iter_items(
*args: Any,
**kwargs: Any,
) -> Iterator[T_References]:
"""Equivalent to SymbolicReference.iter_items, but will return non-detached
references as well."""
"""Equivalent to
:meth:`SymbolicReference.iter_items <git.refs.symbolic.SymbolicReference.iter_items>`,
but will return non-detached references as well."""
return cls._iter_items(repo, common_path)

# }END interface
Expand Down
2 changes: 1 addition & 1 deletion git/refs/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def delete(cls, repo: "Repo", *refs: "RemoteReference", **kwargs: Any) -> None:
"""Delete the given remote references.

:note:
kwargs are given for comparability with the base class method as we
`kwargs` are given for comparability with the base class method as we
should not narrow the signature.
"""
repo.git.branch("-d", "-r", *refs)
Expand Down
44 changes: 22 additions & 22 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SymbolicReference:
This does not point to a specific commit, but to another
:class:`~git.refs.head.Head`, which itself specifies a commit.

A typical example for a symbolic reference is ``HEAD``.
A typical example for a symbolic reference is :class:`~git.refs.head.HEAD`.
"""

__slots__ = ("repo", "path")
Expand Down Expand Up @@ -115,8 +115,8 @@ def _get_packed_refs_path(cls, repo: "Repo") -> str:

@classmethod
def _iter_packed_refs(cls, repo: "Repo") -> Iterator[Tuple[str, str]]:
"""Return an iterator yielding pairs of sha1/path pairs (as strings)
for the corresponding refs.
"""Return an iterator yielding pairs of sha1/path pairs (as strings) for the
corresponding refs.

:note:
The packed refs file will be kept open as long as we iterate.
Expand Down Expand Up @@ -226,9 +226,9 @@ def _get_ref_info_helper(
"""
:return:
(str(sha), str(target_ref_path)) if available, the sha the file at rela_path
points to, or None.
points to, or ``None``.

target_ref_path is the reference we point to, or None.
target_ref_path is the reference we point to, or ``None``.
"""
if ref_path:
cls._check_ref_name_valid(ref_path)
Expand Down Expand Up @@ -273,7 +273,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
:return: (str(sha), str(target_ref_path)) if available, the sha the file at
rela_path points to, or None.

target_ref_path is the reference we point to, or None.
target_ref_path is the reference we point to, or ``None``.
"""
return cls._get_ref_info_helper(repo, ref_path)

Expand Down Expand Up @@ -313,7 +313,7 @@ def set_commit(
:class:`~git.objects.commit.Commit`.

:raise ValueError:
If `commit` is not a :class:`~git.objects.commit.Commit` object or doesn't
If `commit` is not a :class:`~git.objects.commit.Commit` object, nor does it
point to a commit.

:return:
Expand Down Expand Up @@ -357,7 +357,7 @@ def set_object(
to.

:param logmsg:
If not None, the message will be used in the reflog entry to be written.
If not ``None``, the message will be used in the reflog entry to be written.
Otherwise the reflog is not altered.

:note:
Expand Down Expand Up @@ -491,8 +491,8 @@ def set_reference(
def is_valid(self) -> bool:
"""
:return:
True if the reference is valid, hence it can be read and points to a valid
object or reference.
``True`` if the reference is valid, hence it can be read and points to a
valid object or reference.
"""
try:
self.object
Expand All @@ -505,7 +505,7 @@ def is_valid(self) -> bool:
def is_detached(self) -> bool:
"""
:return:
True if we are a detached reference, hence we point to a specific commit
``True`` if we are a detached reference, hence we point to a specific commit
instead to another reference.
"""
try:
Expand Down Expand Up @@ -565,7 +565,7 @@ def log_append(
def log_entry(self, index: int) -> "RefLogEntry":
"""
:return:
RefLogEntry at the given index
:class:`~git.refs.log.RefLogEntry` at the given index

:param index:
Python list compatible positive or negative index.
Expand All @@ -582,7 +582,7 @@ def to_full_path(cls, path: Union[PathLike, "SymbolicReference"]) -> PathLike:
"""
:return:
String with a full repository-relative path which can be used to initialize
a Reference instance, for instance by using
a :class:`~git.refs.reference.Reference` instance, for instance by using
:meth:`Reference.from_path <git.refs.reference.Reference.from_path>`.
"""
if isinstance(path, SymbolicReference):
Expand Down Expand Up @@ -666,7 +666,7 @@ def _create(
) -> T_References:
"""Internal method used to create a new symbolic reference.

If `resolve` is False, the reference will be taken as is, creating a proper
If `resolve` is ``False``, the reference will be taken as is, creating a proper
symbolic reference. Otherwise it will be resolved to the corresponding object
and a detached symbolic reference will be created instead.
"""
Expand Down Expand Up @@ -722,12 +722,12 @@ def create(
If it is a commit-ish, the symbolic ref will be detached.

:param force:
If True, force creation even if a symbolic reference with that name already
exists. Raise :class:`OSError` otherwise.
If ``True``, force creation even if a symbolic reference with that name
already exists. Raise :class:`OSError` otherwise.

:param logmsg:
If not None, the message to append to the reflog.
If None, no reflog entry is written.
If not ``None``, the message to append to the reflog.
If ``None``, no reflog entry is written.

:return:
Newly created symbolic reference
Expand All @@ -751,8 +751,8 @@ def rename(self, new_path: PathLike, force: bool = False) -> "SymbolicReference"
In case this is a symbolic ref, there is no implied prefix.

:param force:
If True, the rename will succeed even if a head with the target name already
exists. It will be overwritten in that case.
If ``True``, the rename will succeed even if a head with the target name
already exists. It will be overwritten in that case.

:return:
self
Expand Down Expand Up @@ -847,8 +847,8 @@ def iter_items(
:param common_path:
Optional keyword argument to the path which is to be shared by all returned
Ref objects.
Defaults to class specific portion if None, ensuring that only refs suitable
for the actual class are returned.
Defaults to class specific portion if ``None``, ensuring that only refs
suitable for the actual class are returned.

:return:
A list of :class:`SymbolicReference`, each guaranteed to be a symbolic ref
Expand Down