diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-07-11 12:30:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 12:30:59 +0800 |
commit | 9523033fd1ff499ae3d151b23b851b7e2b64bf75 (patch) | |
tree | c2f7b467186269926c48c4b2cf02d8364dc39751 /git/objects/submodule/util.py | |
parent | 0a6d9d669979cc5a89ca73f8f4843cba47b4486a (diff) | |
parent | 94c66525a6e7d5c74a9aee65d14630bb674439f7 (diff) | |
download | gitpython-9523033fd1ff499ae3d151b23b851b7e2b64bf75.tar.gz |
Merge pull request #1285 from Yobmod/main
Finish initial typing of Index and Submodule
Diffstat (limited to 'git/objects/submodule/util.py')
-rw-r--r-- | git/objects/submodule/util.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py index 5290000b..a776af88 100644 --- a/git/objects/submodule/util.py +++ b/git/objects/submodule/util.py @@ -5,11 +5,20 @@ from io import BytesIO import weakref -from typing import Any, TYPE_CHECKING, Union +# typing ----------------------------------------------------------------------- + +from typing import Any, Sequence, TYPE_CHECKING, Union + +from git.types import PathLike if TYPE_CHECKING: from .base import Submodule from weakref import ReferenceType + from git.repo import Repo + from git.refs import Head + from git import Remote + from git.refs import RemoteReference + __all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch', 'SubmoduleConfigParser') @@ -17,23 +26,23 @@ __all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch', #{ Utilities -def sm_section(name): +def sm_section(name: str) -> str: """:return: section title used in .gitmodules configuration file""" - return 'submodule "%s"' % name + return f'submodule "{name}"' -def sm_name(section): +def sm_name(section: str) -> str: """:return: name of the submodule as parsed from the section name""" section = section.strip() return section[11:-1] -def mkhead(repo, path): +def mkhead(repo: 'Repo', path: PathLike) -> 'Head': """:return: New branch/head instance""" return git.Head(repo, git.Head.to_full_path(path)) -def find_first_remote_branch(remotes, branch_name): +def find_first_remote_branch(remotes: Sequence['Remote'], branch_name: str) -> 'RemoteReference': """Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError""" for remote in remotes: try: @@ -92,7 +101,7 @@ class SubmoduleConfigParser(GitConfigParser): #{ Overridden Methods def write(self) -> None: - rval = super(SubmoduleConfigParser, self).write() + rval: None = super(SubmoduleConfigParser, self).write() self.flush_to_index() return rval # END overridden methods |