Skip to content

Commit 038dc69

Browse files
committed
cmd/git(refactor[typing]): Narrow config value types
why: Document the supported shapes for git --config values. what: - Add GitConfigValue alias and use it for config parameters - Type the config stringify helper to match
1 parent 173c2c8 commit 038dc69

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from libvcs._internal.types import StrOrBytesPath, StrPath
1717

1818
_CMD = StrOrBytesPath | Sequence[StrOrBytesPath]
19+
GitConfigValue: t.TypeAlias = bool | int | float | StrPath
1920

2021

2122
class Git:
@@ -141,7 +142,7 @@ def run(
141142
noglob_pathspecs: bool | None = None,
142143
icase_pathspecs: bool | None = None,
143144
no_optional_locks: bool | None = None,
144-
config: dict[str, t.Any] | None = None,
145+
config: dict[str, GitConfigValue] | None = None,
145146
config_env: str | None = None,
146147
# Pass-through to run()
147148
log_in_real_time: bool = False,
@@ -241,7 +242,7 @@ def run(
241242
if config is not None:
242243
assert isinstance(config, dict)
243244

244-
def stringify(v: t.Any) -> str:
245+
def stringify(v: GitConfigValue) -> str:
245246
if isinstance(v, bool):
246247
return "true" if v else "false"
247248
if not isinstance(v, str):
@@ -316,7 +317,7 @@ def clone(
316317
verbose: bool | None = None,
317318
quiet: bool | None = None,
318319
# Pass-through to run
319-
config: dict[str, t.Any] | None = None,
320+
config: dict[str, GitConfigValue] | None = None,
320321
log_in_real_time: bool = False,
321322
# Special behavior
322323
check_returncode: bool | None = None,

0 commit comments

Comments
 (0)