Skip to content

Commit 887c4fd

Browse files
committed
cmd/git(refactor[typing]): Type submodule status data
why: Git submodule parsing returns a fixed schema. what: - Add GitSubmoduleData TypedDict - Use it for _ls() return and list typing
1 parent f00495d commit 887c4fd

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
GitConfigValue: t.TypeAlias = bool | int | float | StrPath
2020

2121

22+
class GitSubmoduleData(t.TypedDict):
23+
"""Structured submodule data returned by _ls()."""
24+
25+
name: str
26+
path: str
27+
sha: str
28+
url: str | None
29+
branch: str | None
30+
status_prefix: str
31+
description: str
32+
33+
2234
class Git:
2335
"""Run commands directly on a git repository."""
2436

@@ -3387,7 +3399,7 @@ def _ls(
33873399
# Pass-through to run()
33883400
log_in_real_time: bool = False,
33893401
check_returncode: bool | None = None,
3390-
) -> list[dict[str, t.Any]]:
3402+
) -> list[GitSubmoduleData]:
33913403
"""Parse submodule status output into structured data.
33923404
33933405
Parameters
@@ -3399,7 +3411,7 @@ def _ls(
33993411
34003412
Returns
34013413
-------
3402-
list[dict[str, Any]]
3414+
list[GitSubmoduleData]
34033415
List of parsed submodule data.
34043416
34053417
Examples
@@ -3422,7 +3434,7 @@ def _ls(
34223434
log_in_real_time=log_in_real_time,
34233435
)
34243436

3425-
submodules: list[dict[str, t.Any]] = []
3437+
submodules: list[GitSubmoduleData] = []
34263438

34273439
for line in result.strip().split("\n"):
34283440
if not line:

0 commit comments

Comments
 (0)