Skip to content

Revise comments, docstrings, some messages, and a bit of code #1725

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 36 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7dd2095
Fix docstrings that intend '\' literally
EliahKagan Oct 10, 2023
ffcbf07
Put all regex patterns in r-strings
EliahKagan Oct 10, 2023
2c94b6a
Remove r prefix from strings that need not be raw
EliahKagan Oct 10, 2023
35fd65b
Fix _index_from_*_format docstrings (proc reading)
EliahKagan Oct 15, 2023
5af7446
Fix case in IndexObject.abspath exception message
EliahKagan Oct 16, 2023
692e59e
Remove Commit._deserialize doc for param_from_rev_list
EliahKagan Oct 16, 2023
ab46192
Add missing space in Submodule.update debug message
EliahKagan Oct 17, 2023
1114828
Remove obsolete comment in Submodule.module
EliahKagan Oct 18, 2023
f95d4fd
Clarify "master repository" in RootModule docs
EliahKagan Oct 18, 2023
9fea488
Change spelling from "commit'ish" to "commit-ish"
EliahKagan Oct 18, 2023
4536b63
Update git-source citation in Reference.set_object
EliahKagan Oct 18, 2023
59d208c
Fix message in SymbolicReference.from_path
EliahKagan Oct 18, 2023
add46d9
Use "is" to compare __class__
EliahKagan Oct 18, 2023
cd16a35
Revise docstrings and comments for clarity and formatting
EliahKagan Oct 18, 2023
e8343e2
Firm up comment about is_win in util.is_cygwin_git
EliahKagan Oct 18, 2023
f78587f
Remove explicit inheritance from object
EliahKagan Oct 18, 2023
0327f8f
Make all one-element __slots__ be tuples
EliahKagan Oct 18, 2023
d4a87c1
Revise comments in tests used to generate tutorials
EliahKagan Oct 22, 2023
11fce8a
Revise docstrings/comments in most other test modules
EliahKagan Oct 20, 2023
cf9243a
Add a module docstring to tstrunner.py
EliahKagan Oct 23, 2023
b5c3ca4
Slightly improve readability of installation-test strings
EliahKagan Oct 23, 2023
f444470
More wording improvements (in git module)
EliahKagan Oct 23, 2023
db317f1
Change :returns: to :return:
EliahKagan Oct 23, 2023
720e4bb
Fix TestBigRepoR.setUp info message
EliahKagan Oct 23, 2023
faa19ac
Remove outdated git_daemon_launched Windows info
EliahKagan Oct 24, 2023
bffc537
Revise docstrings/comments in test helpers
EliahKagan Oct 24, 2023
30f49d9
Revise docstrings/comments in performance tests
EliahKagan Oct 24, 2023
8d3efc5
Remove explicit inheritance from object in test suite
EliahKagan Oct 24, 2023
a5fc1d8
Improve consistency of "END" comments
EliahKagan Oct 24, 2023
c2eb6b5
Add missing comment revisions in git/objects/submodule/base.py
EliahKagan Oct 24, 2023
ddb4417
Improve consistency of "END" comments in test suite
EliahKagan Oct 24, 2023
1d3f275
Avoid making "END" notation more verbose
EliahKagan Oct 30, 2023
81dad7e
Add missing comment revisions in git/index/base.py
EliahKagan Oct 30, 2023
a040edb
Shorten some docstring references with tilde notation
EliahKagan Oct 30, 2023
af1b5d4
Fix commented *.py names at the top of modules
EliahKagan Oct 30, 2023
b970d42
Remove encoding declarations
EliahKagan Oct 30, 2023
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
More wording improvements (in git module)
This futher improves some wording in docstrings and comments in a
handful of places within the git module.
  • Loading branch information
EliahKagan committed Oct 23, 2023
commit f444470bc2614b6b148ec4d8761ac804f72343b3
2 changes: 1 addition & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ class CatFileContentStream:
stream once our sized content region is empty.

If not all data are read to the end of the object's lifetime, we read the
rest to assure the underlying stream continues to work.
rest to ensure the underlying stream continues to work.
"""

__slots__: Tuple[str, ...] = ("_stream", "_nbr", "_size")
Expand Down
13 changes: 5 additions & 8 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
T_OMD_value = TypeVar("T_OMD_value", str, bytes, int, float, bool)

if sys.version_info[:3] < (3, 7, 2):
# typing.Ordereddict not added until py 3.7.2
# typing.Ordereddict not added until Python 3.7.2.
from collections import OrderedDict

OrderedDict_OMD = OrderedDict
Expand All @@ -73,13 +73,10 @@
log = logging.getLogger("git.config")
log.addHandler(logging.NullHandler())

# invariants
# represents the configuration level of a configuration file


# The configuration level of a configuration file.
CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository")


# Section pattern to detect conditional includes.
# https://git-scm.com/docs/git-config#_conditional_includes
CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"")
Expand Down Expand Up @@ -603,7 +600,7 @@ def read(self) -> None: # type: ignore[override]
files_to_read = [self._file_or_files]
else: # for lists or tuples
files_to_read = list(self._file_or_files)
# end assure we have a copy of the paths to handle
# end ensure we have a copy of the paths to handle

seen = set(files_to_read)
num_read_include_files = 0
Expand All @@ -612,7 +609,7 @@ def read(self) -> None: # type: ignore[override]
file_ok = False

if hasattr(file_path, "seek"):
# Must be a file objectfile-object.
# Must be a file-object.
file_path = cast(IO[bytes], file_path) # TODO: Replace with assert to narrow type, once sure.
self._read(file_path, file_path.name)
else:
Expand All @@ -626,7 +623,7 @@ def read(self) -> None: # type: ignore[override]
continue

# Read includes and append those that we didn't handle yet.
# We expect all paths to be normalized and absolute (and will assure that is the case).
# We expect all paths to be normalized and absolute (and will ensure that is the case).
if self._has_includes():
for _, include_path in self._included_paths():
if include_path.startswith("~"):
Expand Down
4 changes: 2 additions & 2 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ def diff(
the respective tree.
* If :class:`Index <Diffable.Index>`, it will be compared against the index.
* If :attr:`git.NULL_TREE`, it will compare against the empty tree.
* It defaults to :class:`Index <Diffable.Index>` to assure the method will
not by-default fail on bare repositories.
* It defaults to :class:`Index <Diffable.Index>` so that the method will not
by default fail on bare repositories.

:param paths:
This a list of paths or a single path to limit the diff to. It will only
Expand Down
8 changes: 4 additions & 4 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
resolve more cases in a commonly correct manner. Specify trivial=True as kwarg
to override that.

As the underlying git-read-tree command takes into account the current index,
it will be temporarily moved out of the way to assure there are no unsuspected
interferences.
As the underlying git-read-tree command takes into account the current
index, it will be temporarily moved out of the way to prevent any unexpected
interference.
"""
if len(treeish) == 0 or len(treeish) > 3:
raise ValueError("Please specify between 1 and 3 treeish, got %i" % len(treeish))
Expand All @@ -366,7 +366,7 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
# Move current index out of the way - otherwise the merge may fail
# as it considers existing entries. Moving it essentially clears the index.
# Unfortunately there is no 'soft' way to do it.
# The TemporaryFileSwap assure the original file get put back.
# The TemporaryFileSwap ensures the original file gets put back.

stack.enter_context(TemporaryFileSwap(join_path_native(repo.git_dir, "index")))
repo.git.read_tree(*arg_list, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def update(

if progress is None:
progress = RootUpdateProgress()
# END assure progress is set
# END ensure progress is set

prefix = ""
if dry_run:
Expand Down Expand Up @@ -300,7 +300,7 @@ def update(
smr.rename(orig_name)

# Early on, we verified that the our current tracking branch
# exists in the remote. Now we have to assure that the
# exists in the remote. Now we have to ensure that the
# sha we point to is still contained in the new remote
# tracking branch.
smsha = sm.binsha
Expand Down Expand Up @@ -367,7 +367,7 @@ def update(
except OSError:
# ...or reuse the existing one.
tbr = git.Head(smm, sm.branch_path)
# END assure tracking branch exists
# END ensure tracking branch exists

tbr.set_tracking_branch(find_first_remote_branch(smmr, sm.branch_name))
# NOTE: All head-resetting is done in the base implementation of update
Expand Down
4 changes: 2 additions & 2 deletions git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def add(self, sha: bytes, mode: int, name: str, force: bool = False) -> "TreeMod
return self

def add_unchecked(self, binsha: bytes, mode: int, name: str) -> None:
"""Add the given item to the tree. Its correctness is assumed, which
puts the caller into responsibility to assure the input is correct.
"""Add the given item to the tree. Its correctness is assumed, so it is the
caller's responsibility to ensure that the input is correct.

For more information on the parameters, see :meth:`add`.

Expand Down
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ def archive(
path = cast(Union[PathLike, List[PathLike], Tuple[PathLike, ...]], path)
if not isinstance(path, (tuple, list)):
path = [path]
# end assure paths is list
# end ensure paths is list (or tuple)
self.git.archive("--", treeish, *path, **kwargs)
return self

Expand Down
10 changes: 5 additions & 5 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,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.

This is only needed to play it safe on Windows and to assure nice paths that only
This is only needed to play it safe on Windows and to ensure nice paths that only
use '\'.
"""
return to_native_path(join_path(a, *p))
Expand Down Expand Up @@ -1185,8 +1185,8 @@ def __init__(cls, name: str, bases: Tuple, clsdict: Dict) -> None:


class Iterable(metaclass=IterableClassWatcher):
"""Defines an interface for iterable items which is to assure a uniform
way to retrieve and iterate items within the git repository."""
"""Defines an interface for iterable items, so there is a uniform way to retrieve
and iterate items within the git repository."""

__slots__ = ()

Expand Down Expand Up @@ -1221,8 +1221,8 @@ def iter_items(cls, repo: "Repo", *args: Any, **kwargs: Any) -> Any:

@runtime_checkable
class IterableObj(Protocol):
"""Defines an interface for iterable items which is to assure a uniform
way to retrieve and iterate items within the git repository.
"""Defines an interface for iterable items, so there is a uniform way to retrieve
and iterate items within the git repository.

Subclasses = [Submodule, Commit, Reference, PushInfo, FetchInfo, Remote]
"""
Expand Down