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
Fully qualify non-builtin exceptions in :raise:
This expands exceptions from git.exc and gitdb.exc in :raise:
sections of docstrings, to include those qualifiers.

This serves a few purposes. The main benefits are:

- Immediately clarify which exceptions are not built-in ones, as
  not all readers are necessarily familiar with all built-in
  exceptions.

- Distinguish exceptions defined in GitPython (in git.exc) from
  those defined in gitdb (in gitdb.exc). Although the gitdb
  exceptions GitPython uses are imported into git.exc and listed
  in __all__, they are still not introduced in GitPython, which is
  relevant for (a) preventing confusion, so developers don't think
  they accidentally imported a different same-named exception,
  (b) understanding why they do not have documentation in the
  generated GitPython docs.

It also has these minor benefits:

- May help sphinx-autodoc find them. In practice I think this is
  unlikely to be necessary.

- Most other references, including references to classes, within
  docstrings in the git module, are now fully qualified, when not
  defined/introduced in the same module. So this is consistent with
  that. This consistency might be more than a minor benefit if
  there were a committment to keep most such refernces fully
  qualified, but this really should not be a goal: especially where
  Sphinx autodoc is guaranteed to be able to resolve them,
  shortening (in some cases, re-shortening) the references in the
  future may lead to better docstring readability.
  • Loading branch information
EliahKagan committed Feb 28, 2024
commit 5ca584444b1fe00d5c52341cd267588e64174d7f
4 changes: 2 additions & 2 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def wait(self, stderr: Union[None, str, bytes] = b"") -> int:
May deadlock if output or error pipes are used and not handled
separately.

:raise GitCommandError:
:raise git.exc.GitCommandError:
If the return status is not 0.
"""
if stderr is None:
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def execute(
Note that git is executed with ``LC_MESSAGES="C"`` to ensure consistent
output regardless of system language.

:raise GitCommandError:
:raise git.exc.GitCommandError:

:note:
If you add additional keyword arguments to the signature of this method,
Expand Down
8 changes: 4 additions & 4 deletions git/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
"""
:return: Full binary 20 byte sha from the given partial hexsha

:raise AmbiguousObjectName:
:raise gitdb.exc.AmbiguousObjectName:

:raise BadObject:
:raise gitdb.exc.BadObject:

:note:
Currently we only raise :class:`BadObject` as git does not communicate
ambiguous objects separately.
Currently we only raise :class:`~gitdb.exc.BadObject` as git does not
communicate ambiguous objects separately.
"""
try:
hexsha, _typename, _size = self._git.get_object_header(partial_hexsha)
Expand Down
6 changes: 3 additions & 3 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> "IndexF
self (containing the merge and possibly unmerged entries in case of
conflicts)

:raise GitCommandError:
:raise git.exc.GitCommandError:
If there is a merge conflict. The error will be raised at the first
conflicting path. If you want to have proper merge resolution to be done by
yourself, you have to commit the changed index (or make a valid tree from
Expand Down Expand Up @@ -624,7 +624,7 @@ def write_tree(self) -> Tree:
:raise ValueError:
If there are no entries in the cache.

:raise UnmergedEntriesError:
:raise git.exc.UnmergedEntriesError:
"""
# We obtain no lock as we just flush our contents to disk as tree.
# If we are a new index, the entries access will load our data accordingly.
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def move(
:raise ValueError:
If only one item was given.

:raise GitCommandError:
:raise git.exc.GitCommandError:
If git could not handle your request.
"""
args = []
Expand Down
2 changes: 1 addition & 1 deletion git/index/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run_commit_hook(name: str, index: "IndexFile", *args: str) -> None:
:param args:
Arguments passed to hook file.

:raise HookExecutionError:
:raise git.exc.HookExecutionError:
"""
hp = hook_path(name, index.repo.git_dir)
if not os.access(hp, os.X_OK):
Expand Down
6 changes: 3 additions & 3 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ def remove(
Doesn't work atomically, as failure to remove any part of the submodule will
leave an inconsistent state.

:raise InvalidGitRepositoryError:
:raise git.exc.InvalidGitRepositoryError:
Thrown if the repository cannot be deleted.

:raise OSError:
Expand Down Expand Up @@ -1382,7 +1382,7 @@ def module(self) -> "Repo":
"""
:return: Repo instance initialized from the repository at our submodule path

:raise InvalidGitRepositoryError:
:raise git.exc.InvalidGitRepositoryError:
If a repository was not available.
This could also mean that it was not yet initialized.
"""
Expand Down Expand Up @@ -1454,7 +1454,7 @@ def branch(self) -> "Head":
:return:
The branch instance that we are to checkout

:raise InvalidGitRepositoryError:
:raise git.exc.InvalidGitRepositoryError:
If our module is not yet checked out.
"""
return mkhead(self.module(), self._branch_path)
Expand Down
2 changes: 1 addition & 1 deletion git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ def create(cls, repo: "Repo", name: str, url: str, allow_unsafe_protocols: bool
:return:
New :class:`Remote` instance

:raise GitCommandError:
:raise git.exc.GitCommandError:
In case an origin with that name already exists.
"""
scmd = "add"
Expand Down
10 changes: 5 additions & 5 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def __init__(
Please note that this was the default behaviour in older versions of
GitPython, which is considered a bug though.

:raise InvalidGitRepositoryError:
:raise git.exc.InvalidGitRepositoryError:

:raise NoSuchPathError:
:raise git.exc.NoSuchPathError:

:return:
git.Repo
:class:`Repo`
"""

epath = path or os.getenv("GIT_DIR")
Expand Down Expand Up @@ -893,7 +893,7 @@ def _set_alternates(self, alts: List[str]) -> None:
The array of string paths representing the alternates at which git should
look for objects, i.e. ``/home/user/repo/.git/objects``.

:raise NoSuchPathError:
:raise git.exc.NoSuchPathError:

:note:
The method does not check for the existence of the paths in `alts`, as the
Expand Down Expand Up @@ -1553,7 +1553,7 @@ def archive(
repository-relative path to a directory or file to place into the archive,
or a list or tuple of multiple paths.

:raise GitCommandError:
:raise git.exc.GitCommandError:
If something went wrong.

:return:
Expand Down
4 changes: 2 additions & 2 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def touch(filename: str) -> str:
def is_git_dir(d: "PathLike") -> bool:
"""This is taken from the git setup.c:is_git_directory function.

:raise WorkTreeRepositoryUnsupported:
:raise git.exc.WorkTreeRepositoryUnsupported:
If it sees a worktree directory. It's quite hacky to do that here, but at least
clearly indicates that we don't support it. There is the unlikely danger to
throw if we see directories which just look like a worktree dir, but are none.
Expand Down Expand Up @@ -234,7 +234,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
``git rev-parse``-compatible revision specification as string. Please see
http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html for details.

:raise BadObject:
:raise gitdb.exc.BadObject:
If the given revision could not be found.

:raise ValueError:
Expand Down