diff --git a/README.rst b/README.rst index d25a07e20..5121952ce 100644 --- a/README.rst +++ b/README.rst @@ -416,7 +416,6 @@ An example ``pyproject.toml`` configuration file: line-length = 80 # Passed to isort and Black, override their config target-version = ["py312"] # Passed to Black, overriding its config log_level = "INFO" - preview = false # Passed to Black, overriding its config [tool.black] line-length = 88 # Overridden by [tool.darker] above @@ -426,7 +425,7 @@ An example ``pyproject.toml`` configuration file: exclude = "test_*\.py" extend_exclude = "/generated/" force_exclude = ".*\.pyi" - preview = true # Overridden above + preview = true # Only supported in [tool.black] [tool.isort] diff --git a/src/darker/config.py b/src/darker/config.py index 8d7806cde..1324901b0 100644 --- a/src/darker/config.py +++ b/src/darker/config.py @@ -24,7 +24,6 @@ class DarkerConfig(BaseConfig, total=False): skip_magic_trailing_comma: bool line_length: int target_version: str - preview: bool class OutputMode: diff --git a/src/darker/tests/test_command_line.py b/src/darker/tests/test_command_line.py index fb6eb5a3b..e8940afda 100644 --- a/src/darker/tests/test_command_line.py +++ b/src/darker/tests/test_command_line.py @@ -305,6 +305,19 @@ def test_parse_command_line_deprecated_option( assert {c.args[0] for c in warn.call_args_list} == expect_warn +def test_parse_command_line_unknown_conffile_option(tmp_path, monkeypatch): + """`parse_command_line` warns about deprecated configuration options.""" + monkeypatch.chdir(tmp_path) + config = {"unknown": "value", "preview": "true"} + (tmp_path / "pyproject.toml").write_text(toml.dumps({"tool": {"darker": config}})) + with pytest.raises( + ConfigurationError, + match=r"Invalid \[tool.darker\] keys in pyproject.toml: preview, unknown", + ): + + parse_command_line(["-"]) + + def test_help_description_without_isort_package(capsys): """``darker --help`` description shows how to add ``isort`` if it's not present""" with isort_present(False): @@ -565,6 +578,16 @@ def test_black_options(monkeypatch, tmpdir, git_repo, options, expect): options=["-t", "py39"], expect=call(target_versions={TargetVersion.PY39}), ), + dict( + config=["preview = true"], + options=[], + expect=call(preview=True), + ), + dict( + config=["preview = false"], + options=["--preview"], + expect=call(preview=True), + ), dict( config=["preview = true"], options=["--preview"],