Skip to content

Commit 1fd9e8c

Browse files
committed
Re-add submodule.util.py types
1 parent 8d2a770 commit 1fd9e8c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

‎git/objects/submodule/util.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,44 @@
55
import weakref
66

77

8-
from typing import Any, TYPE_CHECKING, Union
8+
# typing -----------------------------------------------------------------------
9+
10+
from typing import Any, Sequence, TYPE_CHECKING, Union
11+
12+
from git.types import PathLike
913

1014
if TYPE_CHECKING:
1115
from .base import Submodule
1216
from weakref import ReferenceType
17+
from git.repo import Repo
18+
from git.refs import Head
19+
from git import Remote
20+
from git.refs import RemoteReference
21+
1322

1423
__all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch',
1524
'SubmoduleConfigParser')
1625

1726
#{ Utilities
1827

1928

20-
def sm_section(name):
29+
def sm_section(name: str) -> str:
2130
""":return: section title used in .gitmodules configuration file"""
22-
return 'submodule "%s"' % name
31+
return f'submodule {name}'
2332

2433

25-
def sm_name(section):
34+
def sm_name(section: str) -> str:
2635
""":return: name of the submodule as parsed from the section name"""
2736
section = section.strip()
2837
return section[11:-1]
2938

3039

31-
def mkhead(repo, path):
40+
def mkhead(repo: 'Repo', path: PathLike) -> 'Head':
3241
""":return: New branch/head instance"""
3342
return git.Head(repo, git.Head.to_full_path(path))
3443

3544

36-
def find_first_remote_branch(remotes, branch_name):
45+
def find_first_remote_branch(remotes: Sequence['Remote'], branch_name: str) -> 'RemoteReference':
3746
"""Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
3847
for remote in remotes:
3948
try:
@@ -92,7 +101,7 @@ def flush_to_index(self) -> None:
92101

93102
#{ Overridden Methods
94103
def write(self) -> None:
95-
rval = super(SubmoduleConfigParser, self).write()
104+
rval: None = super(SubmoduleConfigParser, self).write()
96105
self.flush_to_index()
97106
return rval
98107
# END overridden methods

0 commit comments

Comments
 (0)