1212import typing as t
1313
1414from libvcs .sync .git import GitRemote
15+
1516from vcspull .validator import is_valid_config
1617
1718from . import exc
@@ -73,7 +74,7 @@ def extract_repos(
7374 for directory , repos in config .items ():
7475 assert isinstance (repos , dict )
7576 for repo , repo_data in repos .items ():
76- conf : t . Dict [str , t .Any ] = {}
77+ conf : dict [str , t .Any ] = {}
7778
7879 """
7980 repo_name: http://myrepo.com/repo.git
@@ -134,9 +135,11 @@ def is_valid_config_dict(val: t.Any) -> "TypeGuard[ConfigDict]":
134135
135136
136137def find_home_config_files (
137- filetype : list [str ] = [ "json" , "yaml" ]
138+ filetype : t . Optional [ list [str ]] = None
138139) -> list [pathlib .Path ]:
139140 """Return configs of ``.vcspull.{yaml,json}`` in user's home directory."""
141+ if filetype is None :
142+ filetype = ["json" , "yaml" ]
140143 configs : list [pathlib .Path ] = []
141144
142145 yaml_config = pathlib .Path (os .path .expanduser ("~/.vcspull.yaml" ))
@@ -151,7 +154,7 @@ def find_home_config_files(
151154 " quickstart."
152155 )
153156 else :
154- if sum (filter (None , [has_json_config , has_yaml_config ])) > int ( 1 ) :
157+ if sum (filter (None , [has_json_config , has_yaml_config ])) > 1 :
155158 raise exc .MultipleConfigWarning ()
156159 if has_yaml_config :
157160 configs .append (yaml_config )
@@ -163,12 +166,12 @@ def find_home_config_files(
163166
164167def find_config_files (
165168 path : t .Optional [t .Union [list [pathlib .Path ], pathlib .Path ]] = None ,
166- match : t .Union [list [str ], str ] = [ "*" ] ,
169+ match : t .Optional [ t . Union [list [str ], str ]] = None ,
167170 filetype : t .Union [
168171 t .Literal ["json" , "yaml" , "*" ], list [t .Literal ["json" , "yaml" , "*" ]]
169- ] = [ "json" , "yaml" ] ,
172+ ] = None ,
170173 include_home : bool = False ,
171- ) -> t . List [pathlib .Path ]:
174+ ) -> list [pathlib .Path ]:
172175 """Return repos from a directory and match. Not recursive.
173176
174177 Parameters
@@ -192,6 +195,10 @@ def find_config_files(
192195 list :
193196 list of absolute paths to config files.
194197 """
198+ if filetype is None :
199+ filetype = ["json" , "yaml" ]
200+ if match is None :
201+ match = ["*" ]
195202 config_files = []
196203 if path is None :
197204 path = get_config_dir ()
@@ -221,7 +228,7 @@ def find_config_files(
221228
222229def load_configs (
223230 files : list [pathlib .Path ], cwd : pathlib .Path = pathlib .Path .cwd ()
224- ) -> t . List ["ConfigDict" ]:
231+ ) -> list ["ConfigDict" ]:
225232 """Return repos from a list of files.
226233
227234 Parameters
@@ -303,8 +310,8 @@ def detect_duplicate_repos(
303310
304311def in_dir (
305312 config_dir : t .Optional [pathlib .Path ] = None ,
306- extensions : list [str ] = [ ".yml" , ".yaml" , ".json" ] ,
307- ) -> t . List [str ]:
313+ extensions : t . Optional [ list [str ]] = None ,
314+ ) -> list [str ]:
308315 """Return a list of configs in ``config_dir``.
309316
310317 Parameters
@@ -318,6 +325,8 @@ def in_dir(
318325 -------
319326 list
320327 """
328+ if extensions is None :
329+ extensions = [".yml" , ".yaml" , ".json" ]
321330 if config_dir is not None :
322331 config_dir = get_config_dir ()
323332 configs = []
@@ -330,7 +339,7 @@ def in_dir(
330339
331340
332341def filter_repos (
333- config : t . List ["ConfigDict" ],
342+ config : list ["ConfigDict" ],
334343 dir : t .Union [pathlib .Path , t .Literal ["*" ], str , None ] = None ,
335344 vcs_url : t .Union [str , None ] = None ,
336345 name : t .Union [str , None ] = None ,
@@ -382,7 +391,7 @@ def filter_repos(
382391
383392
384393def is_config_file (
385- filename : str , extensions : t .Union [list [str ], str ] = [ ".yml" , ".yaml" , ".json" ]
394+ filename : str , extensions : t .Optional [ t . Union [list [str ], str ]] = None
386395) -> bool :
387396 """Return True if file has a valid config file type.
388397
@@ -397,5 +406,7 @@ def is_config_file(
397406 -------
398407 bool : True if is a valid config file type
399408 """
409+ if extensions is None :
410+ extensions = [".yml" , ".yaml" , ".json" ]
400411 extensions = [extensions ] if isinstance (extensions , str ) else extensions
401412 return any (filename .endswith (e ) for e in extensions )
0 commit comments