Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .PHONY: all format lint test tests test_watch integration_tests docker_tests help extended_tests
  2. # Default target executed when no arguments are given to make.
  3. all: help
  4. # Define a variable for the test file path.
  5. TEST_FILE ?= tests/unit_tests/
  6. test:
  7. uv run --with-editable . pytest $(TEST_FILE)
  8. test_watch:
  9. uv run --with-editable . ptw --snapshot-update --now . -- -vv tests/unit_tests
  10. test_profile:
  11. uv run --with-editable . pytest -vv tests/unit_tests/ --profile-svg
  12. extended_tests:
  13. uv run --with-editable . pytest --only-extended $(TEST_FILE)
  14. ######################
  15. # LINTING AND FORMATTING
  16. ######################
  17. # Define a variable for Python and notebook files.
  18. PYTHON_FILES=src/
  19. MYPY_CACHE=.mypy_cache
  20. lint format: PYTHON_FILES=.
  21. lint_diff format_diff: PYTHON_FILES=$(shell git diff --name-only --diff-filter=d main | grep -E '\.py$$|\.ipynb$$')
  22. lint_package: PYTHON_FILES=src
  23. lint_tests: PYTHON_FILES=tests
  24. lint_tests: MYPY_CACHE=.mypy_cache_test
  25. lint lint_diff lint_package lint_tests:
  26. uv run ruff check .
  27. [ "$(PYTHON_FILES)" = "" ] || uv run ruff format $(PYTHON_FILES) --diff
  28. [ "$(PYTHON_FILES)" = "" ] || uv run ruff check --select I $(PYTHON_FILES)
  29. [ "$(PYTHON_FILES)" = "" ] || uv run mypy --strict $(PYTHON_FILES)
  30. [ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && uv run mypy --strict $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
  31. format format_diff:
  32. uv run ruff format $(PYTHON_FILES)
  33. uv run ruff check --select I --fix $(PYTHON_FILES)
  34. spell_check:
  35. codespell --toml pyproject.toml
  36. spell_fix:
  37. codespell --toml pyproject.toml -w
  38. ######################
  39. # HELP
  40. ######################
  41. help:
  42. @echo '----'
  43. @echo 'format - run code formatters'
  44. @echo 'lint - run linters'
  45. @echo 'test - run unit tests'
  46. @echo 'tests - run unit tests'
  47. @echo 'test TEST_FILE=<test_file> - run all tests in file'
  48. @echo 'test_watch - run unit tests in watch mode'