Skip to content

Commit 797e962

Browse files
committed
Make IndexFile and Diffable .diff() types agree
1 parent b03af05 commit 797e962

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

git/diff.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
if TYPE_CHECKING:
2222
from .objects.tree import Tree
23+
from .objects import Commit
2324
from git.repo.base import Repo
2425
from git.objects.base import IndexObject
2526
from subprocess import Popen
@@ -90,7 +91,7 @@ def _process_diff_args(self, args: List[Union[PathLike, 'Diffable', Type['Diffab
9091
Subclasses can use it to alter the behaviour of the superclass"""
9192
return args
9293

93-
def diff(self, other: Union[Type['Index'], 'Tree', None, str] = Index,
94+
def diff(self, other: Union[Type['Index'], 'Tree', 'Commit', None, str] = Index, # object for git.NULL_TREE
9495
paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
9596
create_patch: bool = False, **kwargs: Any) -> 'DiffIndex':
9697
"""Creates diffs between two items being trees, trees and index or an

git/index/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,8 @@ def reset(self, commit: Union[Commit, 'Reference', str] = 'HEAD', working_tree:
12731273

12741274
# @ default_index, breaks typing for some reason, copied into function
12751275
def diff(self,
1276-
other: Union[git_diff.Diffable.Index, 'IndexFile.Index', Treeish, None, object] = git_diff.Diffable.Index,
1276+
other: Union[Type['git_diff.Diffable.Index'], 'IndexFile.Index',
1277+
'Tree', 'Commit', str, None] = git_diff.Diffable.Index,
12771278
paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
12781279
create_patch: bool = False, **kwargs: Any
12791280
) -> git_diff.DiffIndex:

0 commit comments

Comments
 (0)