From 83773704be0f70e8730573a6007ddd0da2868ba6 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Tue, 26 Apr 2022 21:36:48 +1200 Subject: [PATCH] Add Python Black formatter --- shell.nix | 1 + tests/test_eval.py | 8 ++++---- treefmt.toml | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/shell.nix b/shell.nix index 5c0cd0d..ec82a6c 100644 --- a/shell.nix +++ b/shell.nix @@ -33,6 +33,7 @@ in (pkgs.python3.withPackages (ps: [ ps.pytest + ps.black ])) ]; diff --git a/tests/test_eval.py b/tests/test_eval.py index 48bba7c..68dca79 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -30,11 +30,11 @@ def common_test(extra_args: List[str]) -> None: assert built_job["name"] == "job1" assert built_job["outputs"]["out"].startswith("/nix/store") assert built_job["drvPath"].endswith(".drv") - assert built_job["meta"]['broken'] is False + assert built_job["meta"]["broken"] is False dotted_job = results[1] - assert dotted_job["attr"] == "\"dotted.attr\"" - assert dotted_job["attrPath"] == [ "dotted.attr" ] + assert dotted_job["attr"] == '"dotted.attr"' + assert dotted_job["attrPath"] == ["dotted.attr"] recurse_drv = results[2] assert recurse_drv["attr"] == "recurse.drvB" @@ -46,7 +46,7 @@ def common_test(extra_args: List[str]) -> None: substituted_job = results[4] assert substituted_job["attr"] == "substitutedJob" assert substituted_job["name"].startswith("hello-") - assert substituted_job["meta"]['broken'] is False + assert substituted_job["meta"]["broken"] is False def test_flake() -> None: diff --git a/treefmt.toml b/treefmt.toml index d1280df..19a28ed 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -15,3 +15,7 @@ includes = ["*.nix"] command = "prettier" options = ["--write"] includes = ["*.toml"] + +[formatter.python] +command = "black" +includes = ["*.py"]