From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Wed, 5 Jul 2023 05:45:57 +0000 (-0700) Subject: Better error message for invalid exclude types (#3764) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/cf4cc2981900565ab931aada176abf08a1f5782d?hp=8e618f386995fa89434834e6a793a1057e58112a Better error message for invalid exclude types (#3764) --- diff --git a/CHANGES.md b/CHANGES.md index acb5a82..bfa0216 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -32,6 +32,8 @@ - `.pytest_cache`, `.ruff_cache` and `.vscode` are now excluded by default (#3691) - Fix black not honouring `pyproject.toml` settings when running `--stdin-filename` and the `pyproject.toml` found isn't in the current working directory (#3719) +- Black will now error if `exclude` and `extend-exclude` have invalid data types in + `pyproject.toml`, instead of silently doing the wrong thing (#3764) ### Packaging diff --git a/src/black/__init__.py b/src/black/__init__.py index 222cb3c..b6611be 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -157,6 +157,16 @@ def read_pyproject_toml( "target-version", "Config key target-version must be a list" ) + exclude = config.get("exclude") + if exclude is not None and not isinstance(exclude, str): + raise click.BadOptionUsage("exclude", "Config key exclude must be a string") + + extend_exclude = config.get("extend_exclude") + if extend_exclude is not None and not isinstance(extend_exclude, str): + raise click.BadOptionUsage( + "extend-exclude", "Config key extend-exclude must be a string" + ) + default_map: Dict[str, Any] = {} if ctx.default_map: default_map.update(ctx.default_map)