X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/b2c13de4906411ff0b3e20ec5a61f5803a660119..f90f50a7436ca13517933c290ef007e7cb2e7258:/src/black/__init__.py diff --git a/src/black/__init__.py b/src/black/__init__.py index b32197a..2b2d3d8 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -281,12 +281,7 @@ def parse_pyproject_toml(path_config: str) -> Dict[str, Any]: """ pyproject_toml = toml.load(path_config) config = pyproject_toml.get("tool", {}).get("black", {}) - return { - k.replace("--", "").replace("-", "_"): str(v) - if not isinstance(v, (list, dict)) - else v - for k, v in config.items() - } + return {k.replace("--", "").replace("-", "_"): v for k, v in config.items()} def read_pyproject_toml( @@ -311,6 +306,14 @@ def read_pyproject_toml( if not config: return None + else: + # Sanitize the values to be Click friendly. For more information please see: + # https://github.com/psf/black/issues/1458 + # https://github.com/pallets/click/issues/1567 + config = { + k: str(v) if not isinstance(v, (list, dict)) else v + for k, v in config.items() + } target_version = config.get("target_version") if target_version is not None and not isinstance(target_version, list):