Skip to content

Commit 94344b4

Browse files
committed
Clarify CallableProgress vs. CallableRemoteProgress
This corrects an overstatement in the git.types.CallableProgress docstring, which was introduced recently in 9e47083, and in which I had erroneously claimed that it was the most general type of object passed as a progress reporter for cloning. There are some non-None non-callable types that can also be passed and that are not encompassed by git.types.CallableProgress, somewhat confusingly including CallableRemoteProgress (which like RemoteProgress is not callable; rather, it wraps a callable and forwards progress information to it). In addition, None can be passed, and while git.types.CallableProgress does encompass it, it is not callable. (This is minor by comparison and I just added a brief note for it.) This also further expands the git.types.CallableProgress docstring, as well as the git.util.CallableRemoteProgress docstring, to clarify the distinction between them, as well as what "Callable" really signifies for CallableRemoteProgress (that it wraps and forwards to a callable, rather than itself being callable).
1 parent e4fd2e3 commit 94344b4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Diff for: git/types.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,25 @@
115115
# Progress parameter type alias -----------------------------------------
116116

117117
CallableProgress = Optional[Callable[[int, Union[str, float], Union[str, float, None], str], None]]
118-
"""General type of a progress reporter for cloning.
118+
"""General type of a function or other callable used as a progress reporter for cloning.
119119
120120
This is the type of a function or other callable that reports the progress of a clone,
121121
when passed as a ``progress`` argument to :meth:`Repo.clone <git.repo.base.Repo.clone>`
122122
or :meth:`Repo.clone_from <git.repo.base.Repo.clone_from>`.
123+
124+
:note:
125+
Those :meth:`~git.repo.base.Repo.clone` and :meth:`~git.repo.base.Repo.clone_from`
126+
methods also accept :meth:`~git.util.RemoteProgress` instances, including instances
127+
of its :meth:`~git.util.CallableRemoteProgress` subclass.
128+
129+
:note:
130+
Unlike objects that match this type, :meth:`~git.util.RemoteProgress` instances are
131+
not directly callable, not even when they are instances of
132+
:meth:`~git.util.CallableRemoteProgress`, which wraps a callable and forwards
133+
information to it but is not itself callable.
134+
135+
:note:
136+
This type also allows ``None``, for cloning without reporting progress.
123137
"""
124138

125139
# -----------------------------------------------------------------------------------

Diff for: git/util.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,14 @@ def update(
749749

750750

751751
class CallableRemoteProgress(RemoteProgress):
752-
"""An implementation forwarding updates to any callable."""
752+
"""A :class:`RemoteProgress` implementation forwarding updates to any callable.
753+
754+
:note:
755+
Like direct instances of :class:`RemoteProgress`, instances of this
756+
:class:`CallableRemoteProgress` class are not themselves directly callable.
757+
Rather, instances of this class wrap a callable and forward to it. This should
758+
therefore not be confused with :class:`git.types.CallableProgress`.
759+
"""
753760

754761
__slots__ = ("_callable",)
755762

0 commit comments

Comments
 (0)