Skip to content

Commit e66297a

Browse files
committed
Keep the type of a Commit's parents from being too narrow
The type should be Sequence[Commit], rather than List[Commit] as some type checkers seem already to have been inferring and as some others were caused to infer by the indirect fix that precedes this.
1 parent fe42ca7 commit e66297a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

git/objects/commit.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable):
7979
# INVARIANTS
8080
default_encoding = "UTF-8"
8181

82-
# object configuration
8382
type: Literal["commit"] = "commit"
83+
8484
__slots__ = (
8585
"tree",
8686
"author",
@@ -94,8 +94,11 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable):
9494
"encoding",
9595
"gpgsig",
9696
)
97+
9798
_id_attribute_ = "hexsha"
9899

100+
parents: Sequence["Commit"]
101+
99102
def __init__(
100103
self,
101104
repo: "Repo",
@@ -753,7 +756,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit":
753756
readline = stream.readline
754757
self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, "")
755758

756-
self.parents = [] # type: List[Commit]
759+
self.parents = []
757760
next_line = None
758761
while True:
759762
parent_line = readline()

0 commit comments

Comments
 (0)