Debian Codegraph @

Makefile

raw symbols SCIP
1 # Passed to pytest -k and used to select only tests which match the given
2 # substring expression
3 UT ?=
4
5 # When enabled, tests/type-checking will be more verbose and not capture
6 # stdout/err.
7 V ?=
8
9 # Run uv offline by default
10 OFFLINE ?= 1
11
12 SHELL = /usr/bin/env bash
13 PACKAGE := asyncio_dgram
14
15 # List of files in the repository
16 TEST_FILES := $(shell find test -type f -name '*.py')
17 PKG_FILES := $(shell find $(PACKAGE) -type f -name '*.py')
18 BIN_FILES := $(wildcard bin/*)
19
20 # Inferred targets from file names
21 LINT_TARGETS := example.py $(PKG_FILES) $(BIN_FILES) $(TEST_FILES)
22 TEST_TARGETS := $(TEST_FILES:test/test_%.py=test_%)
23
24 UV := uv --no-progress
25 ifeq ($(OFFLINE), 1)
26 UV := $(UV) --offline
27 endif
28
29 .PHONY: \
30 $(TEST_TARGETS) \
31 sync \
32 format \
33 lint \
34 type-check \
35 test
36
37 default:
38
39 # Purposely ignoring $(OFFLINE) here
40 sync:
41 @uv sync --frozen
42
43 check-format:
44 @$(UV) run black --check $(LINT_TARGETS)
45 format:
46 @$(UV) run black $(LINT_TARGETS)
47 lint:
48 @$(UV) run flake8 --filename='*' $(LINT_TARGETS)
49 type-check:
50 @$(UV) run mypy $(if $(V),--show-error-context) $(PACKAGE) test/ example.py
51 test:
52 @$(UV) run pytest --log-level=DEBUG -W default -v -s
53 $(TEST_TARGETS):
54 @$(UV) run pytest --log-cli-level=DEBUG -W default -v \
55 test/$(@).py \
56 $(if $(V),,-s) \
57 $(if $(UT),-k $(UT))