From a437e9c7b609eaf89b2e01932400d315df3626fa Mon Sep 17 00:00:00 2001 From: Jairo Llopis <973709+yajo@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:52:28 +0000 Subject: [PATCH] pre-commit-hooks: fix conditional dependency on tomli (#200178) * pre-commit-hooks: fix conditional dependency on tomli As seen in https://github.com/pre-commit/pre-commit-hooks/commit/fc88f3fa495385e6b367f7c4c8cf10940ad053da, upstream changed their dependency from `toml` to `tomli>=1.1.0;python_version<"3.11"`. Without this patch, running `check-toml` from this package fails with: ``` Traceback (most recent call last): File "/nix/store/06qpfmlgkhxakgjs8g7gk5jlkczij0m6-python3.10-pre-commit-hooks-4.3.0/bin/.check-toml-wrapped", line 6, in from pre_commit_hooks.check_toml import main File "/nix/store/06qpfmlgkhxakgjs8g7gk5jlkczij0m6-python3.10-pre-commit-hooks-4.3.0/lib/python3.10/site-packages/pre_commit_hooks/check_toml.py", line 10, in import tomli as tomllib ModuleNotFoundError: No module named 'tomli' ``` See https://github.com/pre-commit/pre-commit-hooks/issues/833. * pre-commit-hooks: use lib.optionals helper for clarity Co-authored-by: Fabian Affolter Co-authored-by: Fabian Affolter --- pkgs/development/python-modules/pre-commit-hooks/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pre-commit-hooks/default.nix b/pkgs/development/python-modules/pre-commit-hooks/default.nix index 282dd59a05c0..db3aef0b2bb0 100644 --- a/pkgs/development/python-modules/pre-commit-hooks/default.nix +++ b/pkgs/development/python-modules/pre-commit-hooks/default.nix @@ -6,7 +6,7 @@ , pytestCheckHook , pythonOlder , ruamel-yaml -, toml +, tomli }: buildPythonPackage rec { @@ -25,7 +25,8 @@ buildPythonPackage rec { propagatedBuildInputs = [ ruamel-yaml - toml + ] ++ lib.optionals (pythonOlder "3.11") [ + tomli ]; checkInputs = [