From b659a9eef116f2779ae463297700ef4ddc0911b2 Mon Sep 17 00:00:00 2001 From: Tom Prince <tom.prince@private.storage> Date: Tue, 2 Nov 2021 10:24:32 -0600 Subject: [PATCH] Add black and isort linting. --- pyproject.toml | 12 ++++++++++++ tests.nix | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 72280c9..acfa20b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,3 +27,15 @@ directory = "misc" name = "Misc" showcontent = false + +[tool.black] +target-version = ['py27'] +extend-exclude = ''' +# A regex preceded with ^/ will apply only to files and directories +# in the root of the project. +^/src/_zkapauthorizer/_version.py +''' + +[tool.isort] +profile = "black" +skip = ["src/_zkapauthorizer/_version.py"] diff --git a/tests.nix b/tests.nix index 961d29d..b8b5b39 100644 --- a/tests.nix +++ b/tests.nix @@ -32,6 +32,14 @@ in packagesExtra = [ zkapauthorizer ]; _.hypothesis.postUnpack = ""; }; + + lint-python = mach-nix.mkPython { + python = "python39"; + requirements = '' + isort + black + ''; + }; in pkgs.runCommand "zkapauthorizer-tests" { passthru = { @@ -42,6 +50,8 @@ in pushd ${zkapauthorizer.src} ${python}/bin/pyflakes + ${lint-python}/bin/black --check src + ${lint-python}/bin/isort --check src popd ZKAPAUTHORIZER_HYPOTHESIS_PROFILE=${hypothesisProfile'} ${python}/bin/python -m ${if collectCoverage -- GitLab