From 3ce319f1296a5402079e9280500e96cc1d12fd04 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Tue, 6 Jul 2021 14:06:59 +0100 Subject: Add types to submodule.update() --- git/remote.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 0ef54ea7..739424ee 100644 --- a/git/remote.py +++ b/git/remote.py @@ -42,6 +42,7 @@ from git.types import PathLike, Literal, TBD, TypeGuard, Commit_ish if TYPE_CHECKING: from git.repo.base import Repo + from git.objects.submodule.base import UpdateProgress # from git.objects.commit import Commit # from git.objects import Blob, Tree, TagObject @@ -64,7 +65,9 @@ __all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote') #{ Utilities -def add_progress(kwargs: Any, git: Git, progress: Union[Callable[..., Any], None]) -> Any: +def add_progress(kwargs: Any, git: Git, + progress: Union[RemoteProgress, 'UpdateProgress', Callable[..., RemoteProgress], None] + ) -> Any: """Add the --progress flag to the given kwargs dict if supported by the git command. If the actual progress in the given progress instance is not given, we do not request any progress @@ -794,7 +797,7 @@ class Remote(LazyMixin, IterableObj): config.release() def fetch(self, refspec: Union[str, List[str], None] = None, - progress: Union[Callable[..., Any], None] = None, + progress: Union[RemoteProgress, None, 'UpdateProgress'] = None, verbose: bool = True, **kwargs: Any) -> IterableList[FetchInfo]: """Fetch the latest changes for this remote @@ -841,7 +844,7 @@ class Remote(LazyMixin, IterableObj): return res def pull(self, refspec: Union[str, List[str], None] = None, - progress: Union[Callable[..., Any], None] = None, + progress: Union[RemoteProgress, 'UpdateProgress', None] = None, **kwargs: Any) -> IterableList[FetchInfo]: """Pull changes from the given branch, being the same as a fetch followed by a merge of branch with your local branch. @@ -862,7 +865,7 @@ class Remote(LazyMixin, IterableObj): return res def push(self, refspec: Union[str, List[str], None] = None, - progress: Union[Callable[..., Any], None] = None, + progress: Union[RemoteProgress, 'UpdateProgress', Callable[..., RemoteProgress], None] = None, **kwargs: Any) -> IterableList[PushInfo]: """Push changes from source branch in refspec to target branch in refspec. -- cgit v1.2.1 From 7c6ae2b94cfd1593c12366b6abc0cd5bbb6e07b2 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Fri, 9 Jul 2021 15:07:50 +0100 Subject: Try to distinguation git.diff module from diff.Diff.diff and diff.Daffable.diff() --- git/remote.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 739424ee..2998b987 100644 --- a/git/remote.py +++ b/git/remote.py @@ -469,7 +469,7 @@ class Remote(LazyMixin, IterableObj): def _config_section_name(self) -> str: return 'remote "%s"' % self.name - def _set_cache_(self, attr: str) -> Any: + def _set_cache_(self, attr: str) -> None: if attr == "_config_reader": # NOTE: This is cached as __getattr__ is overridden to return remote config values implicitly, such as # in print(r.pushurl) -- cgit v1.2.1 From e7b685db1bf4d9d6aa3f95f4df3fda5992dab14c Mon Sep 17 00:00:00 2001 From: Yobmod Date: Fri, 9 Jul 2021 15:49:32 +0100 Subject: Rmv Diffable assert, add Remoote.url property --- git/remote.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 2998b987..3c3d3c48 100644 --- a/git/remote.py +++ b/git/remote.py @@ -558,6 +558,14 @@ class Remote(LazyMixin, IterableObj): """ return self.set_url(url, delete=True) + @property + def url(self) -> Union[str, List[str]]: + url_list = list(self.urls) + if len(url_list) == 1: + return url_list[0] + else: + return url_list + @property def urls(self) -> Iterator[str]: """:return: Iterator yielding all configured URL targets on a remote as strings""" -- cgit v1.2.1 From 9bb630f03a276a4f1ecc6d6909f82dc90f533026 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Fri, 9 Jul 2021 15:53:45 +0100 Subject: Add remote.url type --- git/remote.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'git/remote.py') diff --git a/git/remote.py b/git/remote.py index 3c3d3c48..f59b3245 100644 --- a/git/remote.py +++ b/git/remote.py @@ -449,8 +449,9 @@ class Remote(LazyMixin, IterableObj): :param repo: The repository we are a remote of :param name: the name of the remote, i.e. 'origin'""" - self.repo = repo # type: 'Repo' + self.repo = repo self.name = name + self.url: str def __getattr__(self, attr: str) -> Any: """Allows to call this instance like @@ -558,15 +559,7 @@ class Remote(LazyMixin, IterableObj): """ return self.set_url(url, delete=True) - @property - def url(self) -> Union[str, List[str]]: - url_list = list(self.urls) - if len(url_list) == 1: - return url_list[0] - else: - return url_list - - @property + @ property def urls(self) -> Iterator[str]: """:return: Iterator yielding all configured URL targets on a remote as strings""" try: @@ -599,7 +592,7 @@ class Remote(LazyMixin, IterableObj): else: raise ex - @property + @ property def refs(self) -> IterableList[RemoteReference]: """ :return: @@ -610,7 +603,7 @@ class Remote(LazyMixin, IterableObj): out_refs.extend(RemoteReference.list_items(self.repo, remote=self.name)) return out_refs - @property + @ property def stale_refs(self) -> IterableList[Reference]: """ :return: @@ -644,7 +637,7 @@ class Remote(LazyMixin, IterableObj): # END for each line return out_refs - @classmethod + @ classmethod def create(cls, repo: 'Repo', name: str, url: str, **kwargs: Any) -> 'Remote': """Create a new remote to the given repository :param repo: Repository instance that is to receive the new remote @@ -661,7 +654,7 @@ class Remote(LazyMixin, IterableObj): # add is an alias add = create - @classmethod + @ classmethod def remove(cls, repo: 'Repo', name: str) -> str: """Remove the remote with the given name :return: the passed remote name to remove -- cgit v1.2.1