1111from datetime import timedelta
1212from functools import cache
1313from pathlib import Path
14+ from typing import Any , Optional , Union
1415
1516import jsonschema
1617
@@ -36,7 +37,9 @@ def schema():
3637 return yaml .safe_load (file )
3738
3839
39- def construct_build_app_kwargs (config , * , source_filepath = None ):
40+ def construct_build_app_kwargs (
41+ config , * , source_filepath : Union [Path , str , None ] = None
42+ ):
4043 """
4144 Given parsed configuration, construct arguments for build_app(...).
4245
@@ -193,8 +196,8 @@ def construct_build_app_kwargs(config, *, source_filepath=None):
193196 }
194197
195198
196- def merge (configs ) :
197- merged = {"trees" : []}
199+ def merge (configs : dict [ Path , dict [ str , Any ]]) -> dict [ str , Any ] :
200+ merged : dict [ str , Any ] = {"trees" : []}
198201
199202 # These variables are used to produce error messages that point
200203 # to the relevant config file(s).
@@ -304,7 +307,7 @@ def merge(configs):
304307 return merged
305308
306309
307- def parse_configs (config_path ) :
310+ def parse_configs (config_path : Union [ str , Path ]) -> dict [ str , Any ] :
308311 """
309312 Parse configuration file or directory of configuration files.
310313
@@ -318,7 +321,9 @@ def parse_configs(config_path):
318321 filepaths = [config_path ]
319322 elif config_path .is_dir ():
320323 filepaths = [
321- fn for fn in config_path .iterdir () if fn .suffix in (".yml" , ".yaml" )
324+ fn
325+ for fn in config_path .iterdir ()
326+ if fn .suffix in (".yml" , ".yaml" ) and fn .is_file ()
322327 ]
323328 elif not config_path .exists ():
324329 raise ValueError (f"The config path { config_path !s} doesn't exist." )
@@ -328,7 +333,7 @@ def parse_configs(config_path):
328333 f"The config path { config_path !s} exists but is not a file or directory."
329334 )
330335
331- parsed_configs = {}
336+ parsed_configs : dict [ Path , dict [ str , Any ]] = {}
332337 # The sorting here is just to make the order of the results deterministic.
333338 # There is *not* any sorting-based precedence applied.
334339 for filepath in sorted (filepaths ):
0 commit comments