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:49:49 UTC

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

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



##########
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:
       It looks like I have to provide something; otherwise it will just pop the following message in all cases.
   ```
   ubuntu@~/tvm> black --diff --check
   No Path provided. Nothing to do 😴
   ```
   Black version 20.8b1. Not sure if this is due to my local environment issue or something else.




----------------------------------------------------------------
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