Skip to content

Commit 8f176a2

Browse files
committed
ci: check lint with Black
Summary: The Black binary only runs Python 3.6 and up, so we only lint in the Python 3 CI build, but that’s perfectly fine. I’ve moved that build to be first so that we can fail fast. The preceding large sequence of change commits was generated with: ``` #!/bin/sh set -eu black . docformatter -i -r . black . # should be a no-op export GIT_AUTHOR_NAME="TensorBoard Gardener" export GIT_AUTHOR_EMAIL="tensorboard-gardener@google.com" # Commit each directory in order of longest-named directory to # shortest-named, to force a topological ordering. Collapse some select # subtrees to reduce the number of commits. git diff --numstat \ | awk '{ print $3 }' \ | rev \ | cut -d / -f 2- \ | rev \ | sed -e 's#/\(test\|demo\)$##' \ | sed -e 's#^\(tensorboard/compat\)/.*#\1#' \ | sed -e 's#^\(tensorboard/plugins/interactive_inference\)/.*#\1#' \ | sed -e 's#^\(tensorboard/summary\)/.*#\1#' \ | sort -u \ | awk '{ print length($0), $0 }' \ | sort -nrs \ | awk '{ print $2 }' \ | while read -r dir do git add "${dir}" if git commit -m "black: reformat directory ${dir}" >/dev/null 2>&1; then printf 'reformat %s: ' "${dir}" git show --oneline --shortstat | tail -n 1 else printf 'skip %s (covered by subtrees)\n' "${dir}" fi done ``` Test Plan: Running `black --check .` currently passes, as all files have been fixed up. It takes about 0.3 seconds on my machine. wchargin-branch: ci-black
1 parent b7ce827 commit 8f176a2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dist: trusty
22
language: python
33
python:
4-
- "2.7"
54
- "3.6"
5+
- "2.7"
66

77
branches:
88
only:
@@ -46,12 +46,14 @@ before_install:
4646

4747
install:
4848
- elapsed "install"
49+
- "PY3=\"$(python -c 'if __import__(\"sys\").version_info[0] > 2: print(1)')\""
4950
# Older versions of Pip sometimes resolve specifiers like `tf-nightly`
5051
# to versions other than the most recent(!).
5152
- pip install -U pip
5253
# Lint check deps.
5354
- pip install flake8==3.7.8
5455
- pip install yamllint==1.17.0
56+
- if [ -n "${PY3}" ]; then pip install black==19.10b0; fi
5557
# TensorBoard deps.
5658
- pip install futures==3.1.1
5759
- pip install grpcio==1.24.3
@@ -87,6 +89,8 @@ before_script:
8789
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
8890
# Lint frontend code
8991
- yarn lint
92+
# Lint backend code
93+
- if [ -n "${PY3}" ]; then black --check .; fi
9094
# Lint .yaml docs files. Use '# yamllint disable-line rule:foo' to suppress.
9195
- yamllint -c docs/.yamllint docs docs/.yamllint
9296
# Make sure that IPython notebooks have valid Markdown.

0 commit comments

Comments
 (0)