Skip to content

Improve Sphinx role usage, including linking Git manpages #1879

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 10 commits into from
Mar 16, 2024
Prev Previous commit
Use the :exc: role for exceptions
Rather than the more general :class: role that was used for them.
  • Loading branch information
EliahKagan committed Mar 16, 2024
commit a957ae7a94ebede485e94d03da0258a0d2ad79e0
2 changes: 1 addition & 1 deletion git/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def partial_to_complete_sha_hex(self, partial_hexsha: str) -> bytes:
:raise gitdb.exc.BadObject:

:note:
Currently we only raise :class:`~gitdb.exc.BadObject` as git does not
Currently we only raise :exc:`~gitdb.exc.BadObject` as git does not
communicate ambiguous objects separately.
"""
try:
Expand Down
10 changes: 5 additions & 5 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ def resolve_blobs(self, iter_blobs: Iterator[Blob]) -> "IndexFile":
This will effectively remove the index entries of the respective path at all
non-null stages and add the given blob as new stage null blob.

For each path there may only be one blob, otherwise a :class:`ValueError` will
be raised claiming the path is already at stage 0.
For each path there may only be one blob, otherwise a :exc:`ValueError` will be
raised claiming the path is already at stage 0.

:raise ValueError:
If one of the blobs already existed at stage 0.
Expand Down Expand Up @@ -644,8 +644,8 @@ def _process_diff_args(
def _to_relative_path(self, path: PathLike) -> PathLike:
"""
:return:
Version of path relative to our git directory or raise :class:`ValueError`
if it is not within our git directory.
Version of path relative to our git directory or raise :exc:`ValueError` if
it is not within our git directory.

:raise ValueError:
"""
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def checkout(
:param force:
If ``True``, existing files will be overwritten even if they contain local
modifications.
If ``False``, these will trigger a :class:`~git.exc.CheckoutError`.
If ``False``, these will trigger a :exc:`~git.exc.CheckoutError`.

:param fprogress:
See :meth:`IndexFile.add` for signature and explanation.
Expand Down
2 changes: 1 addition & 1 deletion git/objects/submodule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def mkhead(repo: "Repo", path: PathLike) -> "Head":

def find_first_remote_branch(remotes: Sequence["Remote"], branch_name: str) -> "RemoteReference":
"""Find the remote branch matching the name of the given branch or raise
:class:`~git.exc.InvalidGitRepositoryError`."""
:exc:`~git.exc.InvalidGitRepositoryError`."""
for remote in remotes:
try:
return remote.refs[branch_name]
Expand Down
4 changes: 2 additions & 2 deletions git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> "TreeMod
"""Add the given item to the tree.

If an item with the given name already exists, nothing will be done, but a
:class:`ValueError` will be raised if the sha and mode of the existing item do
not match the one you add, unless `force` is ``True``.
:exc:`ValueError` will be raised if the sha and mode of the existing item do not
match the one you add, unless `force` is ``True``.

:param sha:
The 20 or 40 byte sha of the item to add.
Expand Down
2 changes: 1 addition & 1 deletion git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]:

: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 ``False``, :exc:`~git.exc.GitCommandError` will be raised in that
situation.

:param kwargs:
Expand Down
2 changes: 1 addition & 1 deletion git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def require_remote_ref_path(func: Callable[..., _T]) -> Callable[..., _T]:
"""A decorator raising :class:`ValueError` if we are not a valid remote, based on the
"""A decorator raising :exc:`ValueError` if we are not a valid remote, based on the
path."""

def wrapper(self: T_References, *args: Any) -> _T:
Expand Down
2 changes: 1 addition & 1 deletion git/refs/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ def delete(cls, repo: "Repo", *refs: "RemoteReference", **kwargs: Any) -> None:

@classmethod
def create(cls, *args: Any, **kwargs: Any) -> NoReturn:
"""Raise :class:`TypeError`. Defined so the ``create`` method is disabled."""
"""Raise :exc:`TypeError`. Defined so the ``create`` method is disabled."""
raise TypeError("Cannot explicitly create remote references")
2 changes: 1 addition & 1 deletion git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def create(

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

:param logmsg:
If not ``None``, the message to append to the reflog.
Expand Down
4 changes: 2 additions & 2 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def name_to_object(repo: "Repo", name: str, return_ref: bool = False) -> Union[A

:param return_ref:
If ``True``, and name specifies a reference, we will return the reference
instead of the object. Otherwise it will raise :class:`~gitdb.exc.BadObject` or
:class:`~gitdb.exc.BadName`.
instead of the object. Otherwise it will raise :exc:`~gitdb.exc.BadObject` or
:exc:`~gitdb.exc.BadName`.
"""
hexsha: Union[None, str, bytes] = None

Expand Down
2 changes: 1 addition & 1 deletion git/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def assert_never(inp: NoReturn, raise_error: bool = True, exc: Union[Exception,
mismatch and cause a mypy error.

:param raise_error:
If ``True``, will also raise :class:`ValueError` with a general "unhandled
If ``True``, will also raise :exc:`ValueError` with a general "unhandled
literal" message, or the exception object passed as `exc`.

:param exc:
Expand Down
8 changes: 4 additions & 4 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def _read_win_env_flag(name: str, default: bool) -> bool:


def unbare_repo(func: Callable[..., T]) -> Callable[..., T]:
"""Methods with this decorator raise
:class:`~git.exc.InvalidGitRepositoryError` if they encounter a bare repository."""
"""Methods with this decorator raise :exc:`~git.exc.InvalidGitRepositoryError` if
they encounter a bare repository."""

from .exc import InvalidGitRepositoryError

Expand Down Expand Up @@ -1094,8 +1094,8 @@ def __init__(
self._max_block_time = max_block_time_s

def _obtain_lock(self) -> None:
"""This method blocks until it obtained the lock, or raises :class:`IOError` if
it ran out of time or if the parent directory was not available anymore.
"""This method blocks until it obtained the lock, or raises :exc:`IOError` if it
ran out of time or if the parent directory was not available anymore.

If this method returns, you are guaranteed to own the lock.
"""
Expand Down