Skip to content

Commit b4b6e1e

Browse files
committed
Fix IndexFile.commit parent_commits annotation
This changes that parameter's annotation to be equivalent to the annotation of the corresponding Commit.create_from_tree parameter. It had been annotated as the old Commit_ish type, but it passes that argument to Commit.create_from_tree, and it also refers to that method in its docstring for usage. Commit.create_from_tree annotates this argument as an optional list of Commit objects, and if the objects obtained when it iterates them are not Commit instances, then an exception is raised. Even if being able to pass other commit-ish things (or references, strings, etc.) is desirable, that does not currently work. This also improves sorting (and grouping style) of imports in that file (which were being changed already to no longer import the old Commit_ish type).
1 parent ab27827 commit b4b6e1e

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

Diff for: git/index/base.py

+15-28
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@
1111
import glob
1212
from io import BytesIO
1313
import os
14+
import os.path as osp
1415
from stat import S_ISLNK
1516
import subprocess
1617
import sys
1718
import tempfile
1819

19-
from git.compat import (
20-
force_bytes,
21-
defenc,
22-
)
23-
from git.exc import GitCommandError, CheckoutError, GitError, InvalidGitRepositoryError
24-
from git.objects import (
25-
Blob,
26-
Submodule,
27-
Tree,
28-
Object,
29-
Commit,
30-
)
20+
from git.compat import defenc, force_bytes
21+
import git.diff as git_diff
22+
from git.exc import CheckoutError, GitCommandError, GitError, InvalidGitRepositoryError
23+
from git.objects import Blob, Commit, Object, Submodule, Tree
3124
from git.objects.util import Serializable
3225
from git.util import (
3326
LazyMixin,
@@ -41,24 +34,17 @@
4134
from gitdb.base import IStream
4235
from gitdb.db import MemoryDB
4336

44-
import git.diff as git_diff
45-
import os.path as osp
46-
4737
from .fun import (
38+
S_IFGITLINK,
39+
aggressive_tree_merge,
4840
entry_key,
49-
write_cache,
5041
read_cache,
51-
aggressive_tree_merge,
52-
write_tree_from_cache,
53-
stat_mode_to_index_mode,
54-
S_IFGITLINK,
5542
run_commit_hook,
43+
stat_mode_to_index_mode,
44+
write_cache,
45+
write_tree_from_cache,
5646
)
57-
from .typ import (
58-
BaseIndexEntry,
59-
IndexEntry,
60-
StageType,
61-
)
47+
from .typ import BaseIndexEntry, IndexEntry, StageType
6248
from .util import TemporaryFileSwap, post_clear_cache, default_index, git_working_dir
6349

6450
# typing -----------------------------------------------------------------------------
@@ -80,12 +66,13 @@
8066
Union,
8167
)
8268

83-
from git.types import Old_commit_ish, Literal, PathLike
69+
from git.types import Literal, PathLike
8470

8571
if TYPE_CHECKING:
8672
from subprocess import Popen
87-
from git.repo import Repo
73+
8874
from git.refs.reference import Reference
75+
from git.repo import Repo
8976
from git.util import Actor
9077

9178

@@ -1127,7 +1114,7 @@ def move(
11271114
def commit(
11281115
self,
11291116
message: str,
1130-
parent_commits: Union[Old_commit_ish, None] = None,
1117+
parent_commits: Union[List[Commit], None] = None,
11311118
head: bool = True,
11321119
author: Union[None, "Actor"] = None,
11331120
committer: Union[None, "Actor"] = None,

0 commit comments

Comments
 (0)