From c2317a768f4d6b72b9c20d4fbe455af8a0d77c36 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 5 Jul 2021 18:47:44 +0100 Subject: Make bytesIO forwardref --- git/objects/submodule/root.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'git/objects/submodule/root.py') diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index 0af48710..c6746ad8 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -10,6 +10,15 @@ import git import logging +# typing ------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from git.repo import Repo + +# ---------------------------------------------------------------------------- + __all__ = ["RootModule", "RootUpdateProgress"] log = logging.getLogger('git.objects.submodule.root') @@ -42,7 +51,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,7 +64,7 @@ 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 @@ -343,7 +352,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 -- cgit v1.2.1 From a9351347d704db02bd3d1103e9715ff6a999e3f9 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Mon, 5 Jul 2021 19:10:21 +0100 Subject: Add types to submodule.root.py --- git/objects/submodule/root.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'git/objects/submodule/root.py') diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index c6746ad8..bcac5419 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -12,10 +12,13 @@ import logging # typing ------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 # ---------------------------------------------------------------------------- @@ -70,9 +73,11 @@ class RootModule(Submodule): #{ 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 @@ -137,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) @@ -171,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 ############## -- cgit v1.2.1 From eecf1486cf445e2f23585b1bb65097dfebbc9545 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Tue, 6 Jul 2021 15:50:37 +0100 Subject: Rmv root.py types --- git/objects/submodule/root.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'git/objects/submodule/root.py') diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index bcac5419..0af48710 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -10,18 +10,6 @@ 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') @@ -54,7 +42,7 @@ class RootModule(Submodule): k_root_name = '__ROOT__' - def __init__(self, repo: 'Repo'): + def __init__(self, repo): # repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None) super(RootModule, self).__init__( repo, @@ -67,17 +55,15 @@ class RootModule(Submodule): branch_path=git.Head.to_full_path(self.k_head_default) ) - def _clear_cache(self) -> None: + def _clear_cache(self): """May not do anything""" pass #{ Interface - 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': + 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): """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 @@ -142,8 +128,8 @@ class RootModule(Submodule): previous_commit = repo.commit(previous_commit) # obtain commit object # END handle previous commit - psms: 'IterableList[Submodule]' = self.list_items(repo, parent_commit=previous_commit) - sms: 'IterableList[Submodule]' = self.list_items(repo) + psms = self.list_items(repo, parent_commit=previous_commit) + sms = self.list_items(repo) spsms = set(psms) ssms = set(sms) @@ -176,8 +162,8 @@ class RootModule(Submodule): csms = (spsms & ssms) len_csms = len(csms) for i, csm in enumerate(csms): - psm: 'Submodule' = psms[csm.name] - sm: 'Submodule' = sms[csm.name] + psm = psms[csm.name] + sm = sms[csm.name] # PATH CHANGES ############## @@ -357,7 +343,7 @@ class RootModule(Submodule): return self - def module(self) -> 'Repo': + def module(self): """:return: the actual repository containing the submodules""" return self.repo #} END interface -- cgit v1.2.1 From 1eceb8938ec98fad3a3aa2b8ffae5be8b7653976 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Tue, 6 Jul 2021 16:29:02 +0100 Subject: Fix submodule.util.py types --- git/objects/submodule/root.py | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'git/objects/submodule/root.py') 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 -- cgit v1.2.1