From c249b6eb997c274b7c7f5fa326c63ef53d3a62e6 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Thu, 17 Aug 2023 11:24:24 +0200 Subject: [PATCH] Add profile setting to isort hook --- modules/hooks.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 9cb092df..97e93f68 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -54,6 +54,15 @@ in default = null; }; }; + isort = + { + profile = + mkOption { + type = types.enum [ "" "black" "django" "pycharm" "google" "open_stack" "plone" "attrs" "hug" "wemake" "appnexus" ]; + description = lib.mdDoc "Built-in profiles to allow easy interoperability with common projects and code styles."; + default = ""; + }; + }; ormolu = { defaultExtensions = @@ -805,8 +814,16 @@ in { name = "isort"; description = "A Python utility / library to sort imports."; - entry = "${pkgs.python3Packages.isort}/bin/isort"; types = [ "file" "python" ]; + entry = + let + cmdArgs = + mkCmdArgs + (with settings.isort; [ + [ (profile != "") " --profile ${profile}" ] + ]); + in + "${pkgs.python3Packages.isort}/bin/isort${cmdArgs}"; }; latexindent = {