You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/09/14 19:31:19 UTC

[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6469: [Formatting] Fix black script for Python formatting

jroesch commented on a change in pull request #6469:
URL: https://github.com/apache/incubator-tvm/pull/6469#discussion_r488171309



##########
File path: tests/lint/git-black.sh
##########
@@ -46,16 +46,20 @@ fi
 echo "Version Information: $(black --version)"
 
 # Compute Python files which changed to compare.
-IFS=$'\n' read -a FILES -d'\n' < <(git diff --name-only HEAD $1 -- "*.py" "*.pyi") || true
-echo "read returned $?"
+IFS=$'\n' read -a FILES -d'\n' < <(git diff --name-only $1 -- "*.py" "*.pyi") || true
+echo "Read returned $?"
+if [ -z ${FILES+x} ]; then
+    echo "No changes in Python files"
+    exit 0
+fi
 echo "Files: $FILES"
 
 if [[ ${INPLACE_FORMAT} -eq 1 ]]; then
-    echo "Running black on Python files against revision" $1):
+    echo "Running black on Python files against revision" $1:
     CMD=( "black" "${FILES[@]}" )
     echo "${CMD[@]}"
     "${CMD[@]}"
 else
     echo "Running black in checking mode"
-    black --diff --check
+    black --diff --check ${FILES[@]}

Review comment:
       I was intentionally having this check the entire repo, not sure if we want to be incremental when doing the full check vs. being incremental when we are formatting. cc @tqchen 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org