@@ -149,14 +149,30 @@ class Diffable:
149
149
:const:`git.NULL_TREE` and :const:`git.diff.NULL_TREE`.
150
150
"""
151
151
152
- INDEX = Index = INDEX
152
+ INDEX = INDEX
153
153
"""Stand-in indicating you want to diff against the index.
154
154
155
155
See the :meth:`diff` method, which accepts this as a value of its ``other``
156
156
parameter.
157
157
158
158
This is the same as :const:`DiffConstants.INDEX`, and may also be accessed as
159
- :const:`git.INDEX` and :const:`git.diff.INDEX`.
159
+ :const:`git.INDEX` and :const:`git.diff.INDEX`, as well as :class:`Diffable.INDEX`,
160
+ which is kept for backward compatibility (it is now defined an alias of this).
161
+ """
162
+
163
+ Index = INDEX
164
+ """Stand-in indicating you want to diff against the index
165
+ (same as :const:`~Diffable.INDEX`).
166
+
167
+ This is an alias of :const:`~Diffable.INDEX`, for backward compatibility. See
168
+ :const:`~Diffable.INDEX` and :meth:`diff` for details.
169
+
170
+ :note:
171
+ Although always meant for use as an opaque constant, this was formerly defined
172
+ as a class. Its usage is unchanged, but static type annotations that attempt
173
+ to permit only this object must be changed to avoid new mypy errors. This was
174
+ previously not possible to do, though ``Type[Diffable.Index]`` approximated it.
175
+ It is now possible to do precisely, using ``Literal[DiffConstants.INDEX]``.
160
176
"""
161
177
162
178
def _process_diff_args (
@@ -213,10 +229,9 @@ def diff(
213
229
A :class:`DiffIndex` representing the computed diff.
214
230
215
231
:note:
216
- On a bare repository, `other` needs to be provided as
217
- :class:`~Diffable.Index`, or as an instance of
218
- :class:`~git.objects.tree.Tree` or :class:`~git.objects.commit.Commit`, or a
219
- git command error will occur.
232
+ On a bare repository, `other` needs to be provided as :const:`INDEX`, or as
233
+ an instance of :class:`~git.objects.tree.Tree` or
234
+ :class:`~git.objects.commit.Commit`, or a git command error will occur.
220
235
"""
221
236
args : List [Union [PathLike , Diffable ]] = []
222
237
args .append ("--abbrev=40" ) # We need full shas.
0 commit comments