linter.sh 596 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash -e
  2. # Copyright (c) Facebook, Inc. and its affiliates.
  3. {
  4. black --version | grep -E "23\." > /dev/null
  5. } || {
  6. echo "Linter requires 'black==23.*' !"
  7. exit 1
  8. }
  9. ISORT_VERSION=$(isort --version-number)
  10. if [[ "$ISORT_VERSION" != 5.12* ]]; then
  11. echo "Linter requires isort==5.12.0 !"
  12. exit 1
  13. fi
  14. echo "Running isort ..."
  15. isort . --atomic
  16. echo "Running black ..."
  17. black -l 100 .
  18. echo "Running flake8 ..."
  19. if [ -x "$(command -v flake8)" ]; then
  20. flake8 .
  21. else
  22. python3 -m flake8 .
  23. fi
  24. echo "Running mypy..."
  25. mypy --exclude 'setup.py|notebooks' .