pyfmt 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. # pyfmt — formats Python code with Black.
  12. set -euo pipefail
  13. cd "$(dirname "$0")/.."
  14. . misc/shlib/shlib.bash
  15. try bin/pyactivate -m black . "$@"
  16. arg="--fix"
  17. while [[ $# -gt 0 ]]; do
  18. case $1 in
  19. --check)
  20. # ruff only supports --fix, not --check
  21. arg=""
  22. shift
  23. ;;
  24. *)
  25. # Ignore all unknown arguments
  26. shift
  27. ;;
  28. esac
  29. done
  30. # We want empty arg to not do anything
  31. # shellcheck disable=SC2086
  32. try bin/pyactivate -m ruff $arg --extend-exclude=misc/dbt-materialize .
  33. # shellcheck disable=SC2086
  34. try bin/pyactivate -m ruff --target-version=py38 $arg misc/dbt-materialize
  35. try_status_report