summaryrefslogtreecommitdiff
path: root/git/objects/submodule/root.py
diff options
context:
space:
mode:
authorYobmod <yobmod@gmail.com>2021-07-06 16:29:02 +0100
committerYobmod <yobmod@gmail.com>2021-07-06 16:29:02 +0100
commit1eceb8938ec98fad3a3aa2b8ffae5be8b7653976 (patch)
tree6ae03a6f6f768d56296f1756888e85985e10dfcb /git/objects/submodule/root.py
parent1fd9e8c43cadb6459438a9405cd993c005689f53 (diff)
downloadgitpython-1eceb8938ec98fad3a3aa2b8ffae5be8b7653976.tar.gz
Fix submodule.util.py types
Diffstat (limited to 'git/objects/submodule/root.py')
-rw-r--r--git/objects/submodule/root.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index 0af48710..bcac5419 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -10,6 +10,18 @@ import git
import logging
+# typing -------------------------------------------------------------------
+
+from typing import TYPE_CHECKING, Union
+
+from git.types import Commit_ish
+
+if TYPE_CHECKING:
+ from git.repo import Repo
+ from git.util import IterableList
+
+# ----------------------------------------------------------------------------
+
__all__ = ["RootModule", "RootUpdateProgress"]
log = logging.getLogger('git.objects.submodule.root')
@@ -42,7 +54,7 @@ class RootModule(Submodule):
k_root_name = '__ROOT__'
- def __init__(self, repo):
+ def __init__(self, repo: 'Repo'):
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
super(RootModule, self).__init__(
repo,
@@ -55,15 +67,17 @@ class RootModule(Submodule):
branch_path=git.Head.to_full_path(self.k_head_default)
)
- def _clear_cache(self):
+ def _clear_cache(self) -> None:
"""May not do anything"""
pass
#{ Interface
- def update(self, previous_commit=None, recursive=True, force_remove=False, init=True,
- to_latest_revision=False, progress=None, dry_run=False, force_reset=False,
- keep_going=False):
+ def update(self, previous_commit: Union[Commit_ish, None] = None, # type: ignore[override]
+ recursive: bool = True, force_remove: bool = False, init: bool = True,
+ to_latest_revision: bool = False, progress: Union[None, 'RootUpdateProgress'] = None,
+ dry_run: bool = False, force_reset: bool = False, keep_going: bool = False
+ ) -> 'RootModule':
"""Update the submodules of this repository to the current HEAD commit.
This method behaves smartly by determining changes of the path of a submodules
repository, next to changes to the to-be-checked-out commit or the branch to be
@@ -128,8 +142,8 @@ class RootModule(Submodule):
previous_commit = repo.commit(previous_commit) # obtain commit object
# END handle previous commit
- psms = self.list_items(repo, parent_commit=previous_commit)
- sms = self.list_items(repo)
+ psms: 'IterableList[Submodule]' = self.list_items(repo, parent_commit=previous_commit)
+ sms: 'IterableList[Submodule]' = self.list_items(repo)
spsms = set(psms)
ssms = set(sms)
@@ -162,8 +176,8 @@ class RootModule(Submodule):
csms = (spsms & ssms)
len_csms = len(csms)
for i, csm in enumerate(csms):
- psm = psms[csm.name]
- sm = sms[csm.name]
+ psm: 'Submodule' = psms[csm.name]
+ sm: 'Submodule' = sms[csm.name]
# PATH CHANGES
##############
@@ -343,7 +357,7 @@ class RootModule(Submodule):
return self
- def module(self):
+ def module(self) -> 'Repo':
""":return: the actual repository containing the submodules"""
return self.repo
#} END interface