Add types to submodule.update() · gitpython-developers/GitPython@3ce319f · GitHub
Skip to content

Commit 3ce319f

Browse files
committed
Add types to submodule.update()
1 parent a935134 commit 3ce319f

4 files changed

Lines changed: 52 additions & 32 deletions

File tree

git/objects/submodule/base.py

Lines changed: 35 additions & 23 deletions

git/remote.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
if TYPE_CHECKING:
4444
from git.repo.base import Repo
45+
from git.objects.submodule.base import UpdateProgress
4546
# from git.objects.commit import Commit
4647
# from git.objects import Blob, Tree, TagObject
4748

@@ -64,7 +65,9 @@ def is_flagKeyLiteral(inp: str) -> TypeGuard[flagKeyLiteral]:
6465
#{ Utilities
6566

6667

67-
def add_progress(kwargs: Any, git: Git, progress: Union[Callable[..., Any], None]) -> Any:
68+
def add_progress(kwargs: Any, git: Git,
69+
progress: Union[RemoteProgress, 'UpdateProgress', Callable[..., RemoteProgress], None]
70+
) -> Any:
6871
"""Add the --progress flag to the given kwargs dict if supported by the
6972
git command. If the actual progress in the given progress instance is not
7073
given, we do not request any progress
@@ -794,7 +797,7 @@ def _assert_refspec(self) -> None:
794797
config.release()
795798

796799
def fetch(self, refspec: Union[str, List[str], None] = None,
797-
progress: Union[Callable[..., Any], None] = None,
800+
progress: Union[RemoteProgress, None, 'UpdateProgress'] = None,
798801
verbose: bool = True, **kwargs: Any) -> IterableList[FetchInfo]:
799802
"""Fetch the latest changes for this remote
800803
@@ -841,7 +844,7 @@ def fetch(self, refspec: Union[str, List[str], None] = None,
841844
return res
842845

843846
def pull(self, refspec: Union[str, List[str], None] = None,
844-
progress: Union[Callable[..., Any], None] = None,
847+
progress: Union[RemoteProgress, 'UpdateProgress', None] = None,
845848
**kwargs: Any) -> IterableList[FetchInfo]:
846849
"""Pull changes from the given branch, being the same as a fetch followed
847850
by a merge of branch with your local branch.
@@ -862,7 +865,7 @@ def pull(self, refspec: Union[str, List[str], None] = None,
862865
return res
863866

864867
def push(self, refspec: Union[str, List[str], None] = None,
865-
progress: Union[Callable[..., Any], None] = None,
868+
progress: Union[RemoteProgress, 'UpdateProgress', Callable[..., RemoteProgress], None] = None,
866869
**kwargs: Any) -> IterableList[PushInfo]:
867870
"""Push changes from source branch in refspec to target branch in refspec.
868871

git/repo/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
from git.util import IterableList
4949
from git.refs.symbolic import SymbolicReference
5050
from git.objects import Tree
51+
from git.objects.submodule.base import UpdateProgress
52+
from git.remote import RemoteProgress
5153

5254

5355
# -----------------------------------------------------------
@@ -575,7 +577,7 @@ def iter_commits(self, rev: Optional[TBD] = None, paths: Union[PathLike, Sequenc
575577
return Commit.iter_items(self, rev, paths, **kwargs)
576578

577579
def merge_base(self, *rev: TBD, **kwargs: Any
578-
) -> List[Union['SymbolicReference', Commit_ish, None]]:
580+
) -> List[Union[Commit_ish, None]]:
579581
"""Find the closest common ancestor for the given revision (e.g. Commits, Tags, References, etc)
580582
581583
:param rev: At least two revs to find the common ancestor for.
@@ -588,7 +590,7 @@ def merge_base(self, *rev: TBD, **kwargs: Any
588590
raise ValueError("Please specify at least two revs, got only %i" % len(rev))
589591
# end handle input
590592

591-
res = [] # type: List[Union['SymbolicReference', Commit_ish, None]]
593+
res = [] # type: List[Union[Commit_ish, None]]
592594
try:
593595
lines = self.git.merge_base(*rev, **kwargs).splitlines() # List[str]
594596
except GitCommandError as err:
@@ -1014,7 +1016,8 @@ def init(cls, path: PathLike = None, mkdir: bool = True, odbt: Type[GitCmdObject
10141016

10151017
@classmethod
10161018
def _clone(cls, git: 'Git', url: PathLike, path: PathLike, odb_default_type: Type[GitCmdObjectDB],
1017-
progress: Optional[Callable], multi_options: Optional[List[str]] = None, **kwargs: Any
1019+
progress: Union['RemoteProgress', 'UpdateProgress', Callable[..., 'RemoteProgress'], None],
1020+
multi_options: Optional[List[str]] = None, **kwargs: Any
10181021
) -> 'Repo':
10191022
odbt = kwargs.pop('odbt', odb_default_type)
10201023

git/util.py

Lines changed: 4 additions & 2 deletions

0 commit comments

Comments
 (0)