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
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
Further git.util docstring revisions
That I had missed in 1cd73ba.
  • Loading branch information
EliahKagan committed Feb 27, 2024
commit d9fb2f4c8f59f6074493d780a4ba62e89fa9f5d6
52 changes: 27 additions & 25 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ def patch_env(name: str, value: str) -> Generator[None, None, None]:
def rmtree(path: PathLike) -> None:
"""Remove the given directory tree recursively.

:note: We use :func:`shutil.rmtree` but adjust its behaviour to see whether files
that couldn't be deleted are read-only. Windows will not remove them in that
case.
:note:
We use :func:`shutil.rmtree` but adjust its behaviour to see whether files that
couldn't be deleted are read-only. Windows will not remove them in that case.
"""

def handler(function: Callable, path: PathLike, _excinfo: Any) -> None:
Expand Down Expand Up @@ -241,8 +241,8 @@ def rmfile(path: PathLike) -> None:


def stream_copy(source: BinaryIO, destination: BinaryIO, chunk_size: int = 512 * 1024) -> int:
"""Copy all data from the source stream into the destination stream in chunks
of size chunk_size.
"""Copy all data from the `source` stream into the `destination` stream in chunks
of size `chunk_size`.

:return:
Number of bytes written
Expand All @@ -259,8 +259,8 @@ def stream_copy(source: BinaryIO, destination: BinaryIO, chunk_size: int = 512 *


def join_path(a: PathLike, *p: PathLike) -> PathLike:
R"""Join path tokens together similar to osp.join, but always use
``/`` instead of possibly ``\`` on Windows."""
R"""Join path tokens together similar to osp.join, but always use ``/`` instead of
possibly ``\`` on Windows."""
path = str(a)
for b in p:
b = str(b)
Expand Down Expand Up @@ -297,7 +297,7 @@ def to_native_path_linux(path: PathLike) -> str:


def join_path_native(a: PathLike, *p: PathLike) -> PathLike:
R"""Like join_path, but makes sure an OS native path is returned.
R"""Like :func:`join_path`, but makes sure an OS native path is returned.

This is only needed to play it safe on Windows and to ensure nice paths that only
use ``\``.
Expand All @@ -308,10 +308,12 @@ def join_path_native(a: PathLike, *p: PathLike) -> PathLike:
def assure_directory_exists(path: PathLike, is_file: bool = False) -> bool:
"""Make sure that the directory pointed to by path exists.

:param is_file: If True, ``path`` is assumed to be a file and handled correctly.
:param is_file:
If True, `path` is assumed to be a file and handled correctly.
Otherwise it must be a directory.

:return: True if the directory was created, False if it already existed.
:return:
True if the directory was created, False if it already existed.
"""
if is_file:
path = osp.dirname(path)
Expand Down Expand Up @@ -339,7 +341,8 @@ def py_where(program: str, path: Optional[PathLike] = None) -> List[str]:
:func:`is_cygwin_git`. When a search following all shell rules is needed,
:func:`shutil.which` can be used instead.

:note: Neither this function nor :func:`shutil.which` will predict the effect of an
:note:
Neither this function nor :func:`shutil.which` will predict the effect of an
executable search on a native Windows system due to a :class:`subprocess.Popen`
call without ``shell=True``, because shell and non-shell executable search on
Windows differ considerably.
Expand Down Expand Up @@ -550,8 +553,7 @@ def remove_password_if_present(cmdline: Sequence[str]) -> List[str]:
class RemoteProgress:
"""Handler providing an interface to parse progress information emitted by
``git push`` and ``git fetch`` and to dispatch callbacks allowing subclasses to
react to the progress.
"""
react to the progress."""

_num_op_codes: int = 9
(
Expand Down Expand Up @@ -761,8 +763,8 @@ def update(self, *args: Any, **kwargs: Any) -> None:

class Actor:
"""Actors hold information about a person acting on the repository. They
can be committers and authors or anything with a name and an email as
mentioned in the git log entries."""
can be committers and authors or anything with a name and an email as mentioned in
the git log entries."""

# PRECOMPILED REGEX
name_only_regex = re.compile(r"<(.*)>")
Expand Down Expand Up @@ -802,7 +804,7 @@ def __repr__(self) -> str:

@classmethod
def _from_string(cls, string: str) -> "Actor":
"""Create an Actor from a string.
"""Create an :class:`Actor` from a string.

:param string:
The string, which is expected to be in regular git format::
Expand Down Expand Up @@ -868,10 +870,11 @@ def default_name() -> str:
@classmethod
def committer(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint"] = None) -> "Actor":
"""
:return: Actor instance corresponding to the configured committer. It behaves
similar to the git implementation, such that the environment will override
configuration values of `config_reader`. If no value is set at all, it will
be generated.
:return:
:class:`Actor` instance corresponding to the configured committer. It
behaves similar to the git implementation, such that the environment will
override configuration values of `config_reader`. If no value is set at all,
it will be generated.

:param config_reader:
ConfigReader to use to retrieve the values from in case they are not set in
Expand All @@ -887,8 +890,7 @@ def author(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint


class Stats:
"""
Represents stat information as presented by git at the end of a merge. It is
"""Represents stat information as presented by git at the end of a merge. It is
created from the output of a diff operation.

Example::
Expand Down Expand Up @@ -949,9 +951,9 @@ def _list_from_string(cls, repo: "Repo", text: str) -> "Stats":


class IndexFileSHA1Writer:
"""Wrapper around a file-like object that remembers the SHA1 of
the data written to it. It will write a sha when the stream is closed
or if asked for explicitly using :meth:`write_sha`.
"""Wrapper around a file-like object that remembers the SHA1 of the data written to
it. It will write a sha when the stream is closed or if asked for explicitly using
:meth:`write_sha`.

Only useful to the index file.

Expand Down