Skip to content

Commit 1eceb89

Browse files
committed
Fix submodule.util.py types
1 parent 1fd9e8c commit 1eceb89

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

‎git/objects/submodule/root.py

+24-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010

1111
import logging
1212

13+
# typing -------------------------------------------------------------------
14+
15+
from typing import TYPE_CHECKING, Union
16+
17+
from git.types import Commit_ish
18+
19+
if TYPE_CHECKING:
20+
from git.repo import Repo
21+
from git.util import IterableList
22+
23+
# ----------------------------------------------------------------------------
24+
1325
__all__ = ["RootModule", "RootUpdateProgress"]
1426

1527
log = logging.getLogger('git.objects.submodule.root')
@@ -42,7 +54,7 @@ class RootModule(Submodule):
4254

4355
k_root_name = '__ROOT__'
4456

45-
def __init__(self, repo):
57+
def __init__(self, repo: 'Repo'):
4658
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
4759
super(RootModule, self).__init__(
4860
repo,
@@ -55,15 +67,17 @@ def __init__(self, repo):
5567
branch_path=git.Head.to_full_path(self.k_head_default)
5668
)
5769

58-
def _clear_cache(self):
70+
def _clear_cache(self) -> None:
5971
"""May not do anything"""
6072
pass
6173

6274
#{ Interface
6375

64-
def update(self, previous_commit=None, recursive=True, force_remove=False, init=True,
65-
to_latest_revision=False, progress=None, dry_run=False, force_reset=False,
66-
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':
6781
"""Update the submodules of this repository to the current HEAD commit.
6882
This method behaves smartly by determining changes of the path of a submodules
6983
repository, next to changes to the to-be-checked-out commit or the branch to be
@@ -128,8 +142,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
128142
previous_commit = repo.commit(previous_commit) # obtain commit object
129143
# END handle previous commit
130144

131-
psms = self.list_items(repo, parent_commit=previous_commit)
132-
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)
133147
spsms = set(psms)
134148
ssms = set(sms)
135149

@@ -162,8 +176,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
162176
csms = (spsms & ssms)
163177
len_csms = len(csms)
164178
for i, csm in enumerate(csms):
165-
psm = psms[csm.name]
166-
sm = sms[csm.name]
179+
psm: 'Submodule' = psms[csm.name]
180+
sm: 'Submodule' = sms[csm.name]
167181

168182
# PATH CHANGES
169183
##############
@@ -343,7 +357,7 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
343357

344358
return self
345359

346-
def module(self):
360+
def module(self) -> 'Repo':
347361
""":return: the actual repository containing the submodules"""
348362
return self.repo
349363
#} END interface

‎git/objects/submodule/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
def sm_section(name: str) -> str:
3030
""":return: section title used in .gitmodules configuration file"""
31-
return f'submodule {name}'
31+
return f'submodule "{name}"'
3232

3333

3434
def sm_name(section: str) -> str:

0 commit comments

Comments
 (0)