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
Further revise docstrings within git.repo
  • Loading branch information
EliahKagan committed Feb 29, 2024
commit 018ebaf72d2d96b2ca98a46748e857abb829a9d4
74 changes: 40 additions & 34 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class BlameEntry(NamedTuple):


class Repo:
"""Represents a git repository and allows you to query references,
gather commit information, generate diffs, create and clone repositories, and query
the log.
"""Represents a git repository and allows you to query references, father
commit information, generate diffs, create and clone repositories, and query the
log.

The following attributes are worth using:

Expand Down Expand Up @@ -188,16 +188,18 @@ def __init__(
repo = Repo(R"C:\Users\mtrier\Development\git-python\.git")

- In *Cygwin*, `path` may be a ``cygdrive/...`` prefixed path.
- If `path` is None or an empty string, :envvar:`GIT_DIR` is used. If that
environment variable is absent or empty, the current directory is used.
- If `path` is ``None`` or an empty string, :envvar:`GIT_DIR` is used. If
that environment variable is absent or empty, the current directory is
used.

:param odbt:
Object DataBase type - a type which is constructed by providing the
directory containing the database objects, i.e. ``.git/objects``. It will be
used to access all object data
used to access all object data.

:param search_parent_directories:
If True, all parent directories will be searched for a valid repo as well.
If ``True``, all parent directories will be searched for a valid repo as
well.

Please note that this was the default behaviour in older versions of
GitPython, which is considered a bug though.
Expand Down Expand Up @@ -372,7 +374,7 @@ def working_tree_dir(self) -> Optional[PathLike]:
"""
:return:
The working tree directory of our git repository.
If this is a bare repository, None is returned.
If this is a bare repository, ``None`` is returned.
"""
return self._working_tree_dir

Expand All @@ -387,7 +389,7 @@ def common_dir(self) -> PathLike:

@property
def bare(self) -> bool:
""":return: True if the repository is bare"""
""":return: ``True`` if the repository is bare"""
return self._bare

@property
Expand Down Expand Up @@ -450,7 +452,7 @@ def remotes(self) -> "IterableList[Remote]":
def remote(self, name: str = "origin") -> "Remote":
""":return: The remote with the specified name

:raise ValueError
:raise ValueError:
If no remote with such a name exists.
"""
r = Remote(self, name)
Expand Down Expand Up @@ -494,10 +496,13 @@ def create_submodule(self, *args: Any, **kwargs: Any) -> Submodule:
return Submodule.add(self, *args, **kwargs)

def iter_submodules(self, *args: Any, **kwargs: Any) -> Iterator[Submodule]:
"""An iterator yielding Submodule instances, see Traversable interface
for a description of args and kwargs.
"""An iterator yielding Submodule instances.

:return: Iterator
See the `~git.objects.util.Traversable` interface for a description of `args`
and `kwargs`.

:return:
Iterator
"""
return RootModule(self).traverse(*args, **kwargs)

Expand Down Expand Up @@ -554,7 +559,8 @@ def create_head(
) -> "Head":
"""Create a new head within the repository.

:note: For more documentation, please see the
:note:
For more documentation, please see the
:meth:`Head.create <git.refs.head.Head.create>` method.

:return:
Expand Down Expand Up @@ -648,7 +654,7 @@ def config_reader(
configuration files.

:param config_level:
For possible values, see the :meth:`config_writer` method. If None, all
For possible values, see the :meth:`config_writer` method. If ``None``, all
applicable levels will be used. Specify a level in case you know which file
you wish to read to prevent reading multiple files.

Expand Down Expand Up @@ -744,7 +750,7 @@ def iter_commits(

:param rev:
Revision specifier, see ``git rev-parse`` for viable options.
If None, the active branch will be used.
If ``None``, the active branch will be used.

:param paths:
An optional path or a list of paths. If set, only commits that include the
Expand All @@ -759,7 +765,7 @@ def iter_commits(
``"revA...revB"`` revision specifier.

:return:
Iterator of :class:`~git.objects.commit.Commit` objects
Iterator of :class:`~git.objects.commit.Commit` objects
"""
if rev is None:
rev = self.head.commit
Expand Down Expand Up @@ -819,7 +825,7 @@ def is_ancestor(self, ancestor_rev: "Commit", rev: "Commit") -> bool:
Rev to test against `ancestor_rev`.

:return:
True if `ancestor_rev` is an ancestor to `rev`.
``True`` if `ancestor_rev` is an ancestor to `rev`.
"""
try:
self.git.merge_base(ancestor_rev, rev, is_ancestor=True)
Expand Down Expand Up @@ -923,9 +929,9 @@ def is_dirty(
) -> bool:
"""
:return:
True if the repository is considered dirty. By default it will react like a
git-status without untracked files, hence it is dirty if the index or the
working copy have changes.
``True`` if the repository is considered dirty. By default it will react
like a git-status without untracked files, hence it is dirty if the index or
the working copy have changes.
"""
if self._bare:
# Bare repositories with no associated working directory are
Expand Down Expand Up @@ -1036,9 +1042,9 @@ def blame_incremental(self, rev: str | HEAD | None, file: str, **kwargs: Any) ->
stream of :class:`BlameEntry` tuples.

:param rev:
Revision specifier. If None, the blame will include all the latest
uncommitted changes. Otherwise, anything successfully parsed by ``git
rev-parse`` is a valid option.
Revision specifier. If ``None``, the blame will include all the latest
uncommitted changes. Otherwise, anything successfully parsed by
``git rev-parse`` is a valid option.

:return:
Lazy iterator of :class:`BlameEntry` tuples, where the commit indicates the
Expand Down Expand Up @@ -1132,9 +1138,9 @@ def blame(
"""The blame information for the given file at the given revision.

:param rev:
Revision specifier. If None, the blame will include all the latest
Revision specifier. If ``None``, the blame will include all the latest
uncommitted changes. Otherwise, anything successfully parsed by
git-rev-parse is a valid option.
``git rev-parse`` is a valid option.

:return:
list: [git.Commit, list: [<line>]]
Expand Down Expand Up @@ -1286,9 +1292,9 @@ def init(
"""Initialize a git repository at the given path if specified.

:param path:
The full path to the repo (traditionally ends with ``/<name>.git``).
Or None, in which case the repository will be created in the current working
directory.
The full path to the repo (traditionally ends with ``/<name>.git``). Or
``None``, in which case the repository will be created in the current
working directory.

:param mkdir:
If specified, will create the repository directory if it doesn't already
Expand Down Expand Up @@ -1445,7 +1451,7 @@ def clone(
Allow unsafe options to be used, like ``--upload-pack``.

:param kwargs:
* odbt = ObjectDatabase Type, allowing to determine the object database
* ``odbt`` = ObjectDatabase Type, allowing to determine the object database
implementation used by the returned Repo instance.
* All remaining keyword arguments are given to the ``git clone`` command.

Expand Down Expand Up @@ -1547,9 +1553,9 @@ def archive(
:param kwargs:
Additional arguments passed to ``git archive``:

* Use the 'format' argument to define the kind of format. Use specialized
* Use the ``format`` argument to define the kind of format. Use specialized
ostreams to write any format supported by Python.
* You may specify the special **path** keyword, which may either be a
* You may specify the special ``path`` keyword, which may either be a
repository-relative path to a directory or file to place into the archive,
or a list or tuple of multiple paths.

Expand Down Expand Up @@ -1581,7 +1587,7 @@ def has_separate_working_tree(self) -> bool:
to.

:note:
Bare repositories will always return False here.
Bare repositories will always return ``False`` here.
"""
if self.bare:
return False
Expand All @@ -1601,7 +1607,7 @@ def currently_rebasing_on(self) -> Commit | None:
:return:
The commit which is currently being replayed while rebasing.

None if we are not currently rebasing.
``None`` if we are not currently rebasing.
"""
if self.git_dir:
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
Expand Down
8 changes: 4 additions & 4 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def find_submodule_git_dir(d: "PathLike") -> Optional["PathLike"]:
def short_to_long(odb: "GitCmdObjectDB", hexsha: str) -> Optional[bytes]:
"""
:return:
Long hexadecimal sha1 from the given less than 40 byte hexsha or None if no
Long hexadecimal sha1 from the given less than 40 byte hexsha, or ``None`` if no
candidate could be found.

:param hexsha:
Expand All @@ -150,7 +150,7 @@ def name_to_object(
references are supported.

:param return_ref:
If True, and name specifies a reference, we will return the reference
If ``True``, and name specifies a reference, we will return the reference
instead of the object. Otherwise it will raise `~gitdb.exc.BadObject` o
`~gitdb.exc.BadName`.
"""
Expand Down Expand Up @@ -202,7 +202,7 @@ def name_to_object(


def deref_tag(tag: "Tag") -> "TagObject":
"""Recursively dereference a tag and return the resulting object"""
"""Recursively dereference a tag and return the resulting object."""
while True:
try:
tag = tag.object
Expand All @@ -213,7 +213,7 @@ def deref_tag(tag: "Tag") -> "TagObject":


def to_commit(obj: Object) -> Union["Commit", "TagObject"]:
"""Convert the given object to a commit if possible and return it"""
"""Convert the given object to a commit if possible and return it."""
if obj.type == "tag":
obj = deref_tag(obj)

Expand Down