|
5 | 5 | import weakref
|
6 | 6 |
|
7 | 7 |
|
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 |
9 | 13 |
|
10 | 14 | if TYPE_CHECKING:
|
11 | 15 | from .base import Submodule
|
12 | 16 | 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 | + |
13 | 22 |
|
14 | 23 | __all__ = ('sm_section', 'sm_name', 'mkhead', 'find_first_remote_branch',
|
15 | 24 | 'SubmoduleConfigParser')
|
16 | 25 |
|
17 | 26 | #{ Utilities
|
18 | 27 |
|
19 | 28 |
|
20 |
| -def sm_section(name): |
| 29 | +def sm_section(name: str) -> str: |
21 | 30 | """:return: section title used in .gitmodules configuration file"""
|
22 |
| - return 'submodule "%s"' % name |
| 31 | + return f'submodule {name}' |
23 | 32 |
|
24 | 33 |
|
25 |
| -def sm_name(section): |
| 34 | +def sm_name(section: str) -> str: |
26 | 35 | """:return: name of the submodule as parsed from the section name"""
|
27 | 36 | section = section.strip()
|
28 | 37 | return section[11:-1]
|
29 | 38 |
|
30 | 39 |
|
31 |
| -def mkhead(repo, path): |
| 40 | +def mkhead(repo: 'Repo', path: PathLike) -> 'Head': |
32 | 41 | """:return: New branch/head instance"""
|
33 | 42 | return git.Head(repo, git.Head.to_full_path(path))
|
34 | 43 |
|
35 | 44 |
|
36 |
| -def find_first_remote_branch(remotes, branch_name): |
| 45 | +def find_first_remote_branch(remotes: Sequence['Remote'], branch_name: str) -> 'RemoteReference': |
37 | 46 | """Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
|
38 | 47 | for remote in remotes:
|
39 | 48 | try:
|
@@ -92,7 +101,7 @@ def flush_to_index(self) -> None:
|
92 | 101 |
|
93 | 102 | #{ Overridden Methods
|
94 | 103 | def write(self) -> None:
|
95 |
| - rval = super(SubmoduleConfigParser, self).write() |
| 104 | + rval: None = super(SubmoduleConfigParser, self).write() |
96 | 105 | self.flush_to_index()
|
97 | 106 | return rval
|
98 | 107 | # END overridden methods
|
|
0 commit comments