From 2eb0d7b9b047fa77e2e0c5fa4eb08ae61728805c Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Mon, 15 Mar 2021 10:37:38 -0600 Subject: [PATCH] Teach it about isort in addition to black The design of this is starting to break down now and will need to be reworked a bit. --- do-reformat.sh | 2 +- would-reformat.sh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/do-reformat.sh b/do-reformat.sh index 2ba7d23..b566c07 100755 --- a/do-reformat.sh +++ b/do-reformat.sh @@ -26,7 +26,7 @@ if [[ $file_type == "javascript" || \ retval="$?" success_retval=0 elif [[ $file_type == "python" ]]; then - out=$(pipx run black $file 2>/dev/null) + out=$(pipx run black $file 2>/dev/null && pipx run isort $file 2>/dev/null) retval="$?" success_retval=0 else diff --git a/would-reformat.sh b/would-reformat.sh index 98ae967..d031b3d 100755 --- a/would-reformat.sh +++ b/would-reformat.sh @@ -28,11 +28,20 @@ if [[ $file_type = "javascript" || \ would_reformat_retval=1 syntax_error_retval=2 elif [[ $file_type == "python" ]]; then - out=$(pipx run black --check $file 2>/dev/null) - retval="$?" + + out=$(pipx run isort --check $file 2>/dev/null) + isort_retval="$?" + success_retval=0 would_reformat_retval=1 syntax_error_retval=123 + + if [[ x"$isort_retval" = x"0" ]] ; then + out=$(pipx run black --check $file 2>/dev/null) + retval="$?" + else + retval="$isort_retval" + fi else echo -n "ignoring" exit 0