Skip to content

Commit a935134

Browse files
committed
Add types to submodule.root.py
1 parent c2317a7 commit a935134

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

git/objects/submodule/root.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212

1313
# typing -------------------------------------------------------------------
1414

15-
from typing import TYPE_CHECKING
15+
from typing import TYPE_CHECKING, Union
16+
17+
from git.types import Commit_ish
1618

1719
if TYPE_CHECKING:
1820
from git.repo import Repo
21+
from git.util import IterableList
1922

2023
# ----------------------------------------------------------------------------
2124

@@ -70,9 +73,11 @@ def _clear_cache(self) -> None:
7073

7174
#{ Interface
7275

73-
def update(self, previous_commit=None, recursive=True, force_remove=False, init=True,
74-
to_latest_revision=False, progress=None, dry_run=False, force_reset=False,
75-
keep_going=False):
76+
def update(self, previous_commit: Union[Commit_ish, None] = None, # type: ignore[override]
77+
recursive: bool = True, force_remove: bool = False, init: bool = True,
78+
to_latest_revision: bool = False, progress: Union[None, 'RootUpdateProgress'] = None,
79+
dry_run: bool = False, force_reset: bool = False, keep_going: bool = False
80+
) -> 'RootModule':
7681
"""Update the submodules of this repository to the current HEAD commit.
7782
This method behaves smartly by determining changes of the path of a submodules
7883
repository, next to changes to the to-be-checked-out commit or the branch to be
@@ -137,8 +142,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
137142
previous_commit = repo.commit(previous_commit) # obtain commit object
138143
# END handle previous commit
139144

140-
psms = self.list_items(repo, parent_commit=previous_commit)
141-
sms = self.list_items(repo)
145+
psms: 'IterableList[Submodule]' = self.list_items(repo, parent_commit=previous_commit)
146+
sms: 'IterableList[Submodule]' = self.list_items(repo)
142147
spsms = set(psms)
143148
ssms = set(sms)
144149

@@ -171,8 +176,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
171176
csms = (spsms & ssms)
172177
len_csms = len(csms)
173178
for i, csm in enumerate(csms):
174-
psm = psms[csm.name]
175-
sm = sms[csm.name]
179+
psm: 'Submodule' = psms[csm.name]
180+
sm: 'Submodule' = sms[csm.name]
176181

177182
# PATH CHANGES
178183
##############

0 commit comments

Comments
 (0)