Skip to content

Commit cd61eb4

Browse files
committed
Further revise docstrings in second-level modules
Some stuff unintentionally missed in 1cd73ba and some subsequent commits, plus a few further things intentionally omitted there, such as converting True, False, and None literals, to double backticked form (rather than bare or single-backticked).
1 parent e6768ec commit cd61eb4

File tree

7 files changed

+119
-105
lines changed

7 files changed

+119
-105
lines changed

Diff for: git/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ def refresh(path: Optional[PathLike] = None) -> None:
129129
:note:
130130
The *path* parameter is usually omitted and cannot be used to specify a custom
131131
command whose location is looked up in a path search on each call. See
132-
:meth:`Git.refresh` for details on how to achieve this.
132+
:meth:`Git.refresh <git.cmd.Git.refresh>` for details on how to achieve this.
133133
134134
:note:
135-
This calls :meth:`Git.refresh` and sets other global configuration according to
136-
the effect of doing so. As such, this function should usually be used instead of
137-
using :meth:`Git.refresh` or :meth:`FetchInfo.refresh` directly.
135+
This calls :meth:`Git.refresh <git.cmd.Git.refresh>` and sets other global
136+
configuration according to the effect of doing so. As such, this function should
137+
usually be used instead of using :meth:`Git.refresh <git.cmd.Git.refresh>` or
138+
:meth:`FetchInfo.refresh <git.remote.FetchInfo.refresh>` directly.
138139
139140
:note:
140141
This function is called automatically, with no arguments, at import time.

Diff for: git/cmd.py

+54-49
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,25 @@ def handle_process_output(
112112
This function returns once the finalizer returns.
113113
114114
:param process:
115-
:class:`subprocess.Popen` instance
115+
:class:`subprocess.Popen` instance.
116116
117117
:param stdout_handler:
118-
f(stdout_line_string), or None
118+
f(stdout_line_string), or ``None``.
119119
120120
:param stderr_handler:
121-
f(stderr_line_string), or None
121+
f(stderr_line_string), or ``None``.
122122
123123
:param finalizer:
124-
f(proc) - wait for proc to finish
124+
f(proc) - wait for proc to finish.
125125
126126
:param decode_streams:
127127
Assume stdout/stderr streams are binary and decode them before pushing their
128128
contents to handlers.
129-
Set this to False if ``universal_newlines == True`` (then streams are in text
130-
mode) or if decoding must happen later (i.e. for :class:`git.diff.Diff`s).
129+
Set this to ``False`` if ``universal_newlines == True`` (then streams are in
130+
text mode) or if decoding must happen later (i.e. for :class:`~git.diff.Diff`s).
131131
132132
:param kill_after_timeout:
133-
float or None, Default = None
133+
:class:`float` or ``None``, Default = ``None``
134134
135135
To specify a timeout in seconds for the git command, after which the process
136136
should be killed.
@@ -236,7 +236,7 @@ def _safer_popen_windows(
236236
itself be searched automatically by the shell. This wrapper covers all those cases.
237237
238238
:note:
239-
This currently works by setting the ``NoDefaultCurrentDirectoryInExePath``
239+
This currently works by setting the :envvar:`NoDefaultCurrentDirectoryInExePath`
240240
environment variable during subprocess creation. It also takes care of passing
241241
Windows-specific process creation flags, but that is unrelated to path search.
242242
@@ -311,8 +311,8 @@ class Git:
311311
312312
Debugging:
313313
314-
* Set the ``GIT_PYTHON_TRACE`` environment variable print each invocation of the
315-
command to stdout.
314+
* Set the :envvar:`GIT_PYTHON_TRACE` environment variable to print each invocation
315+
of the command to stdout.
316316
* Set its value to ``full`` to see details about the returned values.
317317
"""
318318

@@ -351,7 +351,7 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
351351
"""Enables debugging of GitPython's git commands."""
352352

353353
USE_SHELL = False
354-
"""Deprecated. If set to True, a shell will be used when executing git commands.
354+
"""Deprecated. If set to ``True``, a shell will be used when executing git commands.
355355
356356
Prior to GitPython 2.0.8, this had a narrow purpose in suppressing console windows
357357
in graphical Windows applications. In 2.0.8 and higher, it provides no benefit, as
@@ -401,30 +401,32 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
401401
There are three different ways to specify the command that refreshing causes
402402
to be used for git:
403403
404-
1. Pass no `path` argument and do not set the ``GIT_PYTHON_GIT_EXECUTABLE``
405-
environment variable. The command name ``git`` is used. It is looked up
406-
in a path search by the system, in each command run (roughly similar to
407-
how git is found when running ``git`` commands manually). This is usually
408-
the desired behavior.
404+
1. Pass no `path` argument and do not set the
405+
:envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The command
406+
name ``git`` is used. It is looked up in a path search by the system, in
407+
each command run (roughly similar to how git is found when running
408+
``git`` commands manually). This is usually the desired behavior.
409409
410-
2. Pass no `path` argument but set the ``GIT_PYTHON_GIT_EXECUTABLE``
410+
2. Pass no `path` argument but set the :envvar:`GIT_PYTHON_GIT_EXECUTABLE`
411411
environment variable. The command given as the value of that variable is
412412
used. This may be a simple command or an arbitrary path. It is looked up
413-
in each command run. Setting ``GIT_PYTHON_GIT_EXECUTABLE`` to ``git`` has
414-
the same effect as not setting it.
413+
in each command run. Setting :envvar:`GIT_PYTHON_GIT_EXECUTABLE` to
414+
``git`` has the same effect as not setting it.
415415
416416
3. Pass a `path` argument. This path, if not absolute, is immediately
417417
resolved, relative to the current directory. This resolution occurs at
418418
the time of the refresh. When git commands are run, they are run using
419419
that previously resolved path. If a `path` argument is passed, the
420-
``GIT_PYTHON_GIT_EXECUTABLE`` environment variable is not consulted.
420+
:envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable is not
421+
consulted.
421422
422423
:note:
423424
Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class
424425
attribute, which can be read on the :class:`Git` class or any of its
425426
instances to check what command is used to run git. This attribute should
426-
not be confused with the related ``GIT_PYTHON_GIT_EXECUTABLE`` environment
427-
variable. The class attribute is set no matter how refreshing is performed.
427+
not be confused with the related :envvar:`GIT_PYTHON_GIT_EXECUTABLE`
428+
environment variable. The class attribute is set no matter how refreshing is
429+
performed.
428430
"""
429431
# Discern which path to refresh with.
430432
if path is not None:
@@ -571,9 +573,9 @@ def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
571573
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
572574
"""Remove any backslashes from URLs to be written in config files.
573575
574-
Windows might create config files containing paths with backslashes,
575-
but git stops liking them as it will escape the backslashes. Hence we
576-
undo the escaping just to be sure.
576+
Windows might create config files containing paths with backslashes, but git
577+
stops liking them as it will escape the backslashes. Hence we undo the escaping
578+
just to be sure.
577579
"""
578580
if is_cygwin is None:
579581
is_cygwin = cls.is_cygwin()
@@ -638,8 +640,8 @@ class AutoInterrupt:
638640

639641
__slots__ = ("proc", "args", "status")
640642

641-
# If this is non-zero it will override any status code during
642-
# _terminate, used to prevent race conditions in testing.
643+
# If this is non-zero it will override any status code during _terminate, used
644+
# to prevent race conditions in testing.
643645
_status_code_if_terminate: int = 0
644646

645647
def __init__(self, proc: Union[None, subprocess.Popen], args: Any) -> None:
@@ -844,7 +846,7 @@ def __init__(self, working_dir: Union[None, PathLike] = None):
844846
"""Initialize this instance with:
845847
846848
:param working_dir:
847-
Git directory we should work in. If None, we always work in the current
849+
Git directory we should work in. If ``None``, we always work in the current
848850
directory as returned by :func:`os.getcwd`.
849851
This is meant to be the working tree directory if available, or the
850852
``.git`` directory in case of bare repositories.
@@ -1022,8 +1024,8 @@ def execute(
10221024
This feature only has any effect if `as_process` is False.
10231025
10241026
:param stdout_as_string:
1025-
If False, the command's standard output will be bytes. Otherwise, it will be
1026-
decoded into a string using the default encoding (usually UTF-8).
1027+
If ``False``, the command's standard output will be bytes. Otherwise, it
1028+
will be decoded into a string using the default encoding (usually UTF-8).
10271029
The latter can fail, if the output contains binary data.
10281030
10291031
:param kill_after_timeout:
@@ -1045,15 +1047,16 @@ def execute(
10451047
is manually removed.
10461048
10471049
:param with_stdout:
1048-
If True, default True, we open stdout on the created process.
1050+
If ``True``, default ``True``, we open stdout on the created process.
10491051
10501052
:param universal_newlines:
1051-
If True, pipes will be opened as text, and lines are split at all known line
1052-
endings.
1053+
If ``True``, pipes will be opened as text, and lines are split at all known
1054+
line endings.
10531055
10541056
:param shell:
1055-
Whether to invoke commands through a shell (see `Popen(..., shell=True)`).
1056-
If this is not `None`, it overrides :attr:`USE_SHELL`.
1057+
Whether to invoke commands through a shell
1058+
(see :class:`Popen(..., shell=True) <subprocess.Popen>`).
1059+
If this is not ``None``, it overrides :attr:`USE_SHELL`.
10571060
10581061
Passing ``shell=True`` to this or any other GitPython function should be
10591062
avoided, as it is unsafe under most circumstances. This is because it is
@@ -1064,7 +1067,8 @@ def execute(
10641067
issues.
10651068
10661069
:param env:
1067-
A dictionary of environment variables to be passed to :class:`subprocess.Popen`.
1070+
A dictionary of environment variables to be passed to
1071+
:class:`subprocess.Popen`.
10681072
10691073
:param max_chunk_size:
10701074
Maximum number of bytes in one chunk of data passed to the `output_stream`
@@ -1083,7 +1087,7 @@ def execute(
10831087
* str(output) if extended_output = False (Default)
10841088
* tuple(int(status), str(stdout), str(stderr)) if extended_output = True
10851089
1086-
If output_stream is True, the stdout value will be your output stream:
1090+
If `output_stream` is ``True``, the stdout value will be your output stream:
10871091
10881092
* output_stream if extended_output = False
10891093
* tuple(int(status), output_stream, str(stderr)) if extended_output = True
@@ -1288,7 +1292,7 @@ def update_environment(self, **kwargs: Any) -> Dict[str, Union[str, None]]:
12881292
self.update_environment(**old_env)
12891293
12901294
:param kwargs:
1291-
Environment variables to use for git processes
1295+
Environment variables to use for git processes.
12921296
12931297
:return:
12941298
Dict that maps environment variables to their old values
@@ -1367,8 +1371,8 @@ def __call__(self, **kwargs: Any) -> "Git":
13671371
13681372
:param kwargs:
13691373
A dict of keyword arguments.
1370-
These arguments are passed as in :meth:`_call_process`, but will be
1371-
passed to the git command rather than the subcommand.
1374+
These arguments are passed as in :meth:`_call_process`, but will be passed
1375+
to the git command rather than the subcommand.
13721376
13731377
Examples::
13741378
@@ -1409,16 +1413,16 @@ def _call_process(
14091413
as in ``ls_files`` to call ``ls-files``.
14101414
14111415
:param args:
1412-
The list of arguments. If None is included, it will be pruned.
1413-
This allows your commands to call git more conveniently, as None is realized
1414-
as non-existent.
1416+
The list of arguments. If ``None`` is included, it will be pruned.
1417+
This allows your commands to call git more conveniently, as ``None`` is
1418+
realized as non-existent.
14151419
14161420
:param kwargs:
14171421
Contains key-values for the following:
14181422
14191423
- The :meth:`execute()` kwds, as listed in :var:`execute_kwargs`.
14201424
- "Command options" to be converted by :meth:`transform_kwargs`.
1421-
- The `'insert_kwargs_after'` key which its value must match one of ``*args``.
1425+
- The ``insert_kwargs_after`` key which its value must match one of ``*args``.
14221426
14231427
It also contains any command options, to be appended after the matched arg.
14241428
@@ -1431,9 +1435,9 @@ def _call_process(
14311435
git rev-list max-count 10 --header master
14321436
14331437
:return:
1434-
Same as :meth:`execute`.
1435-
If no args are given, used :meth:`execute`'s default (especially
1436-
``as_process = False``, ``stdout_as_string = True``) and return str.
1438+
Same as :meth:`execute`. If no args are given, used :meth:`execute`'s
1439+
default (especially ``as_process = False``, ``stdout_as_string = True``) and
1440+
return :class:`str`.
14371441
"""
14381442
# Handle optional arguments prior to calling transform_kwargs.
14391443
# Otherwise these'll end up in args, which is bad.
@@ -1480,10 +1484,11 @@ def _parse_object_header(self, header_line: str) -> Tuple[str, str, int]:
14801484
:param header_line:
14811485
<hex_sha> type_string size_as_int
14821486
1483-
:return: (hex_sha, type_string, size_as_int)
1487+
:return:
1488+
(hex_sha, type_string, size_as_int)
14841489
14851490
:raise ValueError:
1486-
If the header contains indication for an error due to incorrect input sha
1491+
If the header contains indication for an error due to incorrect input sha.
14871492
"""
14881493
tokens = header_line.split()
14891494
if len(tokens) != 3:

0 commit comments

Comments
 (0)