Skip to content

Instantly share code, notes, and snippets.

@gotofritz
Last active November 6, 2023 18:41
Show Gist options
  • Save gotofritz/62b58e89d2100448af5503940736bd1f to your computer and use it in GitHub Desktop.
Save gotofritz/62b58e89d2100448af5503940736bd1f to your computer and use it in GitHub Desktop.
Starting point for Python Makefile for Poetry
PYTHON_VERSION ?= 3.10.4
CMD := poetry run
SRC_DIR := src
TESTS_DIR := tests
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: help
lint-mypy: ## checks src and tests with mypy
$(CMD) mypy $(SRC_DIR) $(TESTS_DIR)
.PHONY: lint-mypy
lint-flake: ## checks src and tests with mypy
$(CMD) flake8 $(SRC_DIR) $(TESTS_DIR)
.PHONY: lint-flake
lint-black: ## checks src and tests with mypy
$(CMD) black --check --fast $(SRC_DIR) $(TESTS_DIR)
.PHONY: lint-black
format: ## rewrites code with black and isort
$(CMD) black $(SRC_DIR) $(TESTS_DIR)
$(CMD) isort --recursive $(SRC_DIR) $(TESTS_DIR)
.PHONY: format
lint: lint-black line-flake lint-mypy ## runs all static analysis tools
.PHONY: lint
test: ## runs tests
$(CMD) pytest $(TESTS_DIR)
.PHONY: test
qa: format lint test ## formats code, runs static analysis, runs tests
.PHONY: qa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment