diff options
author | Yobmod <yobmod@gmail.com> | 2021-07-06 16:20:52 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-07-06 16:20:52 +0100 |
commit | 1fd9e8c43cadb6459438a9405cd993c005689f53 (patch) | |
tree | e466766904e21e9a5935347f9f306704003f8b15 | |
parent | 8d2a7703259967f0438a18b5cbc80ee060e15866 (diff) | |
download | gitpython-1fd9e8c43cadb6459438a9405cd993c005689f53.tar.gz |
Re-add submodule.util.py types
-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..cde18d08 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 |