Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (70 loc) · 2.97 KB
/
Copy pathMakefile
File metadata and controls
80 lines (70 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.PHONY: install sync test test-e2e lint format typecheck check generate docs clean build
# Bootstrap: install + dev deps, build the local venv.
install sync:
uv sync --all-extras
# Run the suite (offline; e2e tests are deselected).
test:
uv run pytest
# Run the end-to-end tests against a live API. Needs ZENROWS_API_KEY,
# ZENROWS_CRAWL_BASE_URL and ZENROWS_E2E_CRAWL_URL; see DEVELOPMENT.md.
test-e2e:
uv run pytest -m e2e -s tests/e2e
# Static type check (ty — Astral). Shipped surface only; tests are
# covered by the suite. Generated models.py is excluded in pyproject.
typecheck:
uv run ty check src
# Lint + format + type check (CI mode — no fixes).
check: typecheck
uv run ruff check src/ tests/ acceptance/
uv run ruff format --check src/ tests/ acceptance/
# Lint + format (writes fixes).
lint:
uv run ruff check --fix src/ tests/ acceptance/
format:
uv run ruff format src/ tests/ acceptance/
# Regenerate the pydantic v2 models from the backend's canonical spec.
# docs/openapi.yaml is the SDK-local copy of the spec; refresh it from the
# backend when the API changes.
# Open enums: scripts/open_extensible_enums.py then adds a `_missing_` hook
# (src/zenrows/batch/_open_enum.py) to every enum the spec marks
# `x-extensible-enum: true`, so a value the server adds later parses as an
# UNKNOWN member keeping the raw value. Other (request-side) enums stay strict.
# tests/test_open_enums.py fails if a regeneration drops the hook.
# The HTTP client + facade are HAND-WRITTEN in src/zenrows/batch/client.py;
# only the type definitions come from this command.
generate:
uv run datamodel-codegen \
--input docs/openapi.yaml \
--input-file-type openapi \
--output src/zenrows/batch/models.py \
--output-model-type pydantic_v2.BaseModel \
--target-python-version 3.10 \
--use-schema-description \
--use-field-description \
--use-double-quotes \
--field-constraints \
--use-standard-collections \
--use-union-operator \
--enum-field-as-literal one \
--collapse-root-models \
--use-annotated \
--capitalise-enum-members \
--reuse-model \
--use-default
uv run python scripts/open_extensible_enums.py docs/openapi.yaml src/zenrows/batch/models.py
# Regenerate the markdown API reference (docs/batch-client-reference.md) from
# the SDK's docstrings via pydoc-markdown (ephemeral — no permanent dep). The
# builder relabels internal module headers to public section titles and strips
# the `zenrows.batch._x.` qualifiers, so the private `_module` layout never
# leaks into the customer-facing reference. See scripts/build_reference.py.
docs:
@mkdir -p docs
@uv run --with pydoc-markdown python scripts/build_reference.py > docs/batch-client-reference.md
@echo "wrote docs/batch-client-reference.md ($$(wc -l < docs/batch-client-reference.md) lines)"
# Clean build artifacts + caches.
clean:
rm -rf dist build *.egg-info src/*.egg-info .pytest_cache .ruff_cache
find . -type d -name __pycache__ -prune -exec rm -rf {} +
# Build wheel + sdist via hatchling.
build:
uv build