@@ -48,24 +48,23 @@ def save_config(config: DictConfig) -> Path:
4848 log .warning (f"Error saving config.\n Error: \n { e } ." )
4949
5050
51- def flatten_dict (d : Dict [str , Any ], sep : str = "." , parent_key : str = "" ):
51+ def flatten_dict (d : Dict [str , Any ], * , sep : str = "." , parent_key : str = "" ):
5252 """Recursively flattens a nested dictionary into one level of key-value pairs.
5353
5454 Args:
55- d (Dict[str, Any]): Any dictionary to flatten
56- sep (str): Desired separator for flattening nested keys
57- parent_key (str): Key prefix for children (nested keys), containing parent key
58- names
55+ d (Dict[str, Any]): Any dictionary to flatten.
56+ sep (str, optional): Desired separator for flattening nested keys. Defaults to ".".
57+ parent_key (str, optional): Key prefix for children (nested keys), containing parent key names. Defaults to "".
5958
6059 Example:
61- >>> flatten_dict({"foo": {"bar": "baz"}, "qux"; "quux"}, parent_key ="--")
62- {"foo--bar": "baz", "qux", "quux"}
60+ >>> flatten_dict({"foo": {"bar": "baz"}, "qux": "quux"}, sep ="--")
61+ {"foo--bar": "baz", "qux": "quux"}
6362
6463 Returns:
65- Flattened dictionary
64+ Dict[str, Any]: Flattened dictionary.
6665
6766 Note:
68- Does not unnest dictionaries within list values (i.e. {"foo": [{"bar": "baz}]}})
67+ Does not unnest dictionaries within list values (i.e., {"foo": [{"bar": "baz" }]}).
6968 """
7069 items = []
7170 for k , v in d .items ():
0 commit comments