SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

lint-python.sh (865B)


      1 #!/usr/bin/env bash
      2 # Based on https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/test/lint/lint-python.sh
      3 # Based on Bitcoin Core's test/lint/lint-python.sh
      4 
      5 # E265 block comment should start with '# '
      6 # E402 module level import not at top of file
      7 # E501 line too long
      8 IGNORE_ERRORS="E265,E402,E501"
      9 
     10 EXCLUDE_PATTERNS="docs/*"
     11 
     12 if ! command -v flake8 > /dev/null; then
     13     echo "Skipping Python linting since flake8 is not installed."
     14     exit 0
     15 elif flake8 --version | grep -q "Python 2"; then
     16     echo "Skipping Python linting since flake8 is running under Python 2. Install the Python 3 version of flake8."
     17     exit 0
     18 fi
     19 
     20 if [[ $# == 0 ]]; then
     21     flake8 $(git ls-files "*.py") \
     22         --extend-ignore "${IGNORE_ERRORS}" \
     23         --extend-exclude "${EXCLUDE_PATTERNS}"
     24 else
     25     flake8 "$@" \
     26         --extend-ignore "${IGNORE_ERRORS}"
     27 fi