2323
2424log = logging .getLogger (__name__ )
2525
26+ RepoConfigData : t .TypeAlias = str | pathlib .Path | t .Mapping [str , object ]
27+
2628
2729def create_fmt_subparser (parser : argparse .ArgumentParser ) -> None :
2830 """Create ``vcspull fmt`` argument subparser."""
@@ -53,12 +55,12 @@ def create_fmt_subparser(parser: argparse.ArgumentParser) -> None:
5355 parser .set_defaults (merge_roots = True )
5456
5557
56- def normalize_repo_config (repo_data : object ) -> dict [str , object ]:
58+ def normalize_repo_config (repo_data : RepoConfigData ) -> dict [str , object ]:
5759 """Normalize repository configuration to verbose format.
5860
5961 Parameters
6062 ----------
61- repo_data : Any
63+ repo_data : str | pathlib.Path | Mapping[str, object]
6264 Repository configuration (string URL or dict)
6365
6466 Returns
@@ -69,16 +71,16 @@ def normalize_repo_config(repo_data: object) -> dict[str, object]:
6971 if isinstance (repo_data , str ):
7072 # Convert compact format to verbose format
7173 return {"repo" : repo_data }
72- if isinstance (repo_data , dict ):
73- # If it has 'url' key but not ' repo', convert to use 'repo'
74- if "url" in repo_data and "repo" not in repo_data :
75- normalized = repo_data . copy ()
76- normalized [ "repo" ] = normalized . pop ( "url" )
77- return normalized
78- # Already in correct format or has other fields
79- return t . cast ( "dict[str, object]" , repo_data )
80- # Return as-is for other types
81- return t . cast ( "dict[str, object]" , repo_data )
74+ if isinstance (repo_data , pathlib . Path ):
75+ return { " repo" : str ( repo_data )}
76+ repo_map = dict ( repo_data )
77+ # If it has 'url' key but not 'repo', convert to use 'repo'
78+ if "url" in repo_map and "repo" not in repo_map :
79+ normalized = repo_map . copy ()
80+ normalized [ "repo" ] = normalized . pop ( "url" )
81+ return normalized
82+ # Already in correct format or has other fields
83+ return repo_map
8284
8385
8486def format_config (
@@ -116,7 +118,7 @@ def format_config(
116118 formatted_dir : dict [str , object ] = {}
117119
118120 for repo_name in sorted_repos :
119- repo_data = repos_map [repo_name ]
121+ repo_data = t . cast ( "RepoConfigData" , repos_map [repo_name ])
120122 normalized = normalize_repo_config (repo_data )
121123
122124 # Check if normalization changed anything
0 commit comments