INNER CODE UNIT · Python
inject_snakefmt_config
snakemake/snakefmt · snakefmt/config.py:93
def inject_snakefmt_config(
ctx: click.Context, param: click.Parameter, config_file: Optional[str] = None
) -> Optional[str]:
"""
If no config file argument provided, parses "pyproject.toml" if one exists.
Injects any parsed configuration into the relevant parameters to the click `ctx`.
"""
if config_file is None:
config_file = find_pyproject_toml(ctx.params.get("src", ()))
config = read_snakefmt_config(config_file)
if ctx.default_map is None:
ctx.default_map = {}
ctx.default_map.update(config) # type: ignore # bad types in .pyi
return config_file