.PHONY: test lint typecheck format check clean install-hooks

VENV := .venv/bin

test:
	$(VENV)/python -m pytest tests/ -v

lint:
	$(VENV)/ruff check src/ tests/

typecheck:
	$(VENV)/mypy src/

format:
	$(VENV)/ruff format src/ tests/
	$(VENV)/ruff check --fix src/ tests/

check: format lint typecheck test
	@echo "All checks passed"

install-hooks:
	@printf '#!/bin/sh\nset -e\necho "Running pre-commit checks..."\nmake check\n' > .git/hooks/pre-commit
	@chmod +x .git/hooks/pre-commit
	@echo "Pre-commit hook installed"

clean:
	find . -type d -name __pycache__ -exec rm -rf {} +
	find . -type d -name .pytest_cache -exec rm -rf {} +
	find . -type d -name .mypy_cache -exec rm -rf {} +
