def set_defaults_from_config( context: click.Context, param: click.Parameter, value: Union[str, int], ) -> Path: supplied_paths = context.params.get("path") search_paths = supplied_paths if not search_paths: search_paths = (".", ) project_root = find_project_root([Path(path) for path in search_paths]) file_config = read_config_toml(project_root, CONFIG_FILE) if file_config: config_path = project_root / "pyproject.toml" else: config_path = None context.params["config_path"] = config_path file_config = apply_multi_defaults(file_config, context.params) if context.default_map is None: context.default_map = {} context.default_map.update(file_config) return project_root
def _(root_file, project): root = find_project_root([project / "a/b/c", project / "a/d"]) assert root.resolve() == project.resolve() assert (root / root_file).exists()
def _(): project_root = find_project_root([]) fs_root = os.path.normpath(os.path.abspath(os.sep)) assert project_root == Path(fs_root)