check-python-files.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # check-python-files.sh — check Python files for issues.
  12. set -euo pipefail
  13. cd "$(dirname "$0")/../../../.."
  14. . misc/shlib/shlib.bash
  15. if [[ ! "${MZDEV_NO_PYTHON:-}" ]]; then
  16. pyright_version=$(sh ci/builder/pyright-version.sh)
  17. typecheck_cmd="npx --yes pyright@$pyright_version --warnings"
  18. python_folders=(ci misc/python)
  19. compose_files=$(git_files "**/mzcompose.py" | grep -v "test/")
  20. # NOTE: we actually _want_ the word-splitting behavior on `typecheck_cmd` below,
  21. # so turn off the warning
  22. # shellcheck disable=SC2086
  23. try $typecheck_cmd "${python_folders[@]}" $compose_files "test/"
  24. try bin/pyactivate -m ruff --extend-exclude=misc/dbt-materialize .
  25. # We need to maintain compatibility with older Python versions for this
  26. try bin/pyactivate -m ruff --target-version=py38 misc/dbt-materialize
  27. fi
  28. try_status_report