10
10
11
11
import logging
12
12
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
+
13
25
__all__ = ["RootModule" , "RootUpdateProgress" ]
14
26
15
27
log = logging .getLogger ('git.objects.submodule.root' )
@@ -42,7 +54,7 @@ class RootModule(Submodule):
42
54
43
55
k_root_name = '__ROOT__'
44
56
45
- def __init__ (self , repo ):
57
+ def __init__ (self , repo : 'Repo' ):
46
58
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
47
59
super (RootModule , self ).__init__ (
48
60
repo ,
@@ -55,15 +67,17 @@ def __init__(self, repo):
55
67
branch_path = git .Head .to_full_path (self .k_head_default )
56
68
)
57
69
58
- def _clear_cache (self ):
70
+ def _clear_cache (self ) -> None :
59
71
"""May not do anything"""
60
72
pass
61
73
62
74
#{ Interface
63
75
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' :
67
81
"""Update the submodules of this repository to the current HEAD commit.
68
82
This method behaves smartly by determining changes of the path of a submodules
69
83
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=
128
142
previous_commit = repo .commit (previous_commit ) # obtain commit object
129
143
# END handle previous commit
130
144
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 )
133
147
spsms = set (psms )
134
148
ssms = set (sms )
135
149
@@ -162,8 +176,8 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
162
176
csms = (spsms & ssms )
163
177
len_csms = len (csms )
164
178
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 ]
167
181
168
182
# PATH CHANGES
169
183
##############
@@ -343,7 +357,7 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
343
357
344
358
return self
345
359
346
- def module (self ):
360
+ def module (self ) -> 'Repo' :
347
361
""":return: the actual repository containing the submodules"""
348
362
return self .repo
349
363
#} END interface
0 commit comments