|
4 | 4 | import re |
5 | 5 | import shutil |
6 | 6 | import tempfile |
7 | | -from collections import namedtuple |
8 | 7 | from pathlib import PurePath |
9 | | -from typing import Dict, Generator, List, Optional, Sequence, Tuple |
| 8 | +from typing import Dict, Generator, List, NamedTuple, Optional, Sequence, Tuple |
10 | 9 |
|
11 | 10 | from dfetch.log import get_logger |
12 | 11 | from dfetch.util.cmdline import SubprocessCommandError, run_on_cmdline |
13 | 12 | from dfetch.util.util import in_directory, safe_rmtree |
14 | 13 |
|
15 | 14 | logger = get_logger(__name__) |
16 | 15 |
|
17 | | -Submodule = namedtuple( |
18 | | - "Submodule", ["name", "toplevel", "path", "sha", "url", "branch", "tag"] |
19 | | -) |
| 16 | + |
| 17 | +class Submodule(NamedTuple): |
| 18 | + name: str |
| 19 | + toplevel: str |
| 20 | + path: str |
| 21 | + sha: str |
| 22 | + url: str |
| 23 | + branch: str |
| 24 | + tag: str |
20 | 25 |
|
21 | 26 |
|
22 | 27 | def get_git_version() -> Tuple[str, str]: |
@@ -95,7 +100,7 @@ def _ls_remote(remote: str) -> Dict[str, str]: |
95 | 100 | logger, f"git ls-remote --heads --tags {remote}" |
96 | 101 | ).stdout.decode() |
97 | 102 |
|
98 | | - info = {} |
| 103 | + info: Dict[str, str] = {} |
99 | 104 | for line in filter(lambda x: x, result.split("\n")): |
100 | 105 | sha, ref = [part.strip() for part in f"{line} ".split("\t", maxsplit=1)] |
101 | 106 |
|
@@ -338,7 +343,7 @@ def submodules() -> List[Submodule]: |
338 | 343 | ], |
339 | 344 | ) |
340 | 345 |
|
341 | | - submodules = [] |
| 346 | + submodules: List[Submodule] = [] |
342 | 347 | urls: Dict[str, str] = {} |
343 | 348 | for line in result.stdout.decode().split("\n"): |
344 | 349 | if line: |
|
0 commit comments