From c3903d8e03af5c1e01c1a96919b926c55f45052e Mon Sep 17 00:00:00 2001 From: Yobmod Date: Thu, 24 Jun 2021 14:27:13 +0100 Subject: Make IterableList generic and update throughout --- git/objects/submodule/base.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'git/objects/submodule/base.py') diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 8cf4dd1e..57396a46 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -3,7 +3,6 @@ from io import BytesIO import logging import os import stat -from typing import List from unittest import SkipTest import uuid @@ -27,7 +26,7 @@ from git.exc import ( from git.objects.base import IndexObject, Object from git.objects.util import Traversable from git.util import ( - Iterable, + IterableObj, join_path_native, to_native_path_linux, RemoteProgress, @@ -47,6 +46,15 @@ from .util import ( ) +# typing ---------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from git.util import IterableList + +# ----------------------------------------------------------------------------- + __all__ = ["Submodule", "UpdateProgress"] @@ -74,7 +82,7 @@ UPDWKTREE = UpdateProgress.UPDWKTREE # IndexObject comes via util module, its a 'hacky' fix thanks to pythons import # mechanism which cause plenty of trouble of the only reason for packages and # modules is refactoring - subpackages shouldn't depend on parent packages -class Submodule(IndexObject, Iterable, Traversable): +class Submodule(IndexObject, IterableObj, Traversable): """Implements access to a git submodule. They are special in that their sha represents a commit in the submodule's repository which is to be checked out @@ -136,12 +144,12 @@ class Submodule(IndexObject, Iterable, Traversable): # END handle attribute name @classmethod - def _get_intermediate_items(cls, item: 'Submodule') -> List['Submodule']: # type: ignore + def _get_intermediate_items(cls, item: 'Submodule') -> IterableList['Submodule']: """:return: all the submodules of our module repository""" try: return cls.list_items(item.module()) except InvalidGitRepositoryError: - return [] + return IterableList('') # END handle intermediate items @classmethod @@ -1163,7 +1171,7 @@ class Submodule(IndexObject, Iterable, Traversable): :raise IOError: If the .gitmodules file/blob could not be read""" return self._config_parser_constrained(read_only=True) - def children(self): + def children(self) -> IterableList['Submodule']: """ :return: IterableList(Submodule, ...) an iterable list of submodules instances which are children of this submodule or 0 if the submodule is not checked out""" -- cgit v1.2.1 From 8bf00a6719804c2fc5cca280e9dae6774acc1237 Mon Sep 17 00:00:00 2001 From: Yobmod Date: Thu, 24 Jun 2021 16:16:32 +0100 Subject: fix an import --- git/objects/submodule/base.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'git/objects/submodule/base.py') diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 57396a46..ce0f944e 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -31,7 +31,8 @@ from git.util import ( to_native_path_linux, RemoteProgress, rmtree, - unbare_repo + unbare_repo, + IterableList ) from git.util import HIDE_WINDOWS_KNOWN_ERRORS @@ -48,10 +49,6 @@ from .util import ( # typing ---------------------------------------------------------------------- -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from git.util import IterableList # ----------------------------------------------------------------------------- -- cgit v1.2.1 From d9f9027779931c3cdb04d570df5f01596539791b Mon Sep 17 00:00:00 2001 From: Yobmod Date: Thu, 24 Jun 2021 17:09:51 +0100 Subject: update some TBDs to configparser --- git/objects/submodule/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git/objects/submodule/base.py') diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index ce0f944e..cbf6cd0d 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1158,7 +1158,7 @@ class Submodule(IndexObject, IterableObj, Traversable): """ return self._name - def config_reader(self): + def config_reader(self) -> SectionConstraint: """ :return: ConfigReader instance which allows you to qurey the configuration values of this submodule, as provided by the .gitmodules file -- cgit v1.2.1