-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
276 lines (258 loc) · 12.3 KB
/
pyproject.toml
File metadata and controls
276 lines (258 loc) · 12.3 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
[project]
name = "lantern"
version = "0.5.0"
description = "A prototype data catalogue for BAS discovery metadata."
readme = "README.md"
license = "MIT"
authors = [
{ name = "Felix Fennell", email = "felnne@bas.ac.uk" }
]
requires-python = ">=3.11"
dependencies = [
"authlib>=1.6.9",
"bas-metadata-library>=0.17.0",
"beautifulsoup4>=4.13.4",
"bleach>=6.2.0",
"boto3>=1.42.44",
"boto3-stubs[s3]>=1.42.44",
"cattrs>=25.1.1",
"deepdiff>=8.5.0",
"environs>=14.5.0",
"humanize>=4.12.3",
"inquirer>=3.4.0",
"jinja2>=3.1.6",
"joblib>=1.5.1",
"jsonschema>=4.23.0",
"markdown>=3.8.2",
"markdown-gfm-admonition>=0.1.1",
"pathvalidate>=3.3.1",
"python-gitlab>=8.0.0",
"requests>=2.32.5",
"sentry-sdk>=2.52.0",
"sqlorm-py>=0.4.1",
"sysrsync>=1.1.1",
"truststore>=0.10.4",
]
[dependency-groups]
dev = [
"dunamai>=1.25.0",
"pymarkdownlnt>=0.9.33",
"pytailwindcss>=0.2.0",
"ruff>=0.15.0",
"taskipy>=1.14.1",
"ty>=0.0.15",
"types-lxml>=2025.3.30",
]
test = [
"lxml>=5.4.0",
"moto[s3]>=5.1.6",
"pytest>=8.4.1",
"pytest-cov>=6.2.1",
"pytest-env>=1.1.5",
"pytest-freezer>=0.4.9",
"pytest-mock>=3.14.1",
"pytest-playwright>=0.7.0",
"pytest-random-order>=1.2.0",
"pytest-recording>=0.13.4",
"pytest-unordered>=0.7.0",
"pytest-xdist>=3.8.0",
]
[tool.uv]
exclude-newer-package = { bas-metadata-library = false }
[[tool.uv.index]]
name = "self"
url = "https://gitlab.data.bas.ac.uk/api/v4/projects/1355/packages/pypi/simple"
publish-url = "https://gitlab.data.bas.ac.uk/api/v4/projects/1355/packages/pypi"
explicit = true
[tool.taskipy.variables]
docs_targets = "docs/ README.md CHANGELOG.md"
types_targets = "src/"
targets = "src/ tasks/ tests/"
cov_options = "--cov --cov-report=html"
local_stack_compose = "./resources/dev/docker-compose.yml"
[tool.taskipy.tasks]
# generic dev
build = { cmd = "uv build", help = "Build app package" }
format = { cmd = "ruff format {targets}", help = "Format app", use_vars = true }
lint = { cmd = "ruff check {targets}", help = "Lint app", use_vars = true }
types = { cmd = "ty check {types_targets}", help = "Type check app", use_vars = true }
markdown = { cmd = "pymarkdown scan --recurse {docs_targets}", help = "Lint docs", use_vars = true }
pre-commit = { cmd = "pre-commit run --all-files", help = "Run pre-commit hooks on all files" }
test = { cmd = "pytest", help = "Run tests" }
test-cov = { cmd = "pytest {cov_options}", help = "Run tests with coverage", use_vars = true }
test-reset = { cmd = "pytest --cache-clear", help = "Reset pytest cache and run tests" }
vulnerabilities = { cmd = "uv audit --frozen", help = "Check for insecure dependencies" }
outdated = { cmd = "uv tree --all-groups --outdated --depth=1", help = "List outdated directed dependencies" }
# CI
ci-test = { cmd = "pytest {cov_options} -o junit_family=xunit2 --junitxml=test-results.xml --continue-on-collection-errors", help = "Called by CI", use_vars = true }
# local stack
stack-start = { cmd = "docker-compose -f {local_stack_compose} up -d", help = "Start local dev stack", use_vars = true }
stack-stop = { cmd = "docker-compose -f {local_stack_compose} down", help = "Stop local dev stack", use_vars = true }
# IaC
tfvars-init = { cmd = "op inject --in-file resources/envs/terraform.tfvars.tpl --out-file resources/envs/terraform.tfvars", help = "Initialise Terraform/OpenTofu vars file" }
# app dev
release = { cmd = "python -m tasks.release", help = "Prepapre app release" }
config-init = { cmd = "op inject --in-file resources/dev/.env.tpl --out-file .env", help = "Initialise config file" }
config-check = { cmd = "python -m tasks.config_check", help = "Check app config" }
keys-check = { cmd = "python -m tasks.keys_check", help = "Check admin meta keys" }
css = { cmd = "python -m tasks.css", help = "Regenerate CSS via tailwind" }
css-audit = { cmd = "python -m tasks.css_audit", help = "List CSS styles used in app templates" }
icons-audit = { cmd = "python -m tasks.icons_audit", help = "List icons used in app templates" }
build-test-records = { cmd = "python -m tests.scripts.build_fake_cat", help = "Build test records as a catalogue site" }
build-test-cache = { cmd = "python -m tests.resources.stores.gitlab_cache.refresh", help = "Build test/resource cache" }
# fake CLI
version = { cmd = "uv version", help = "Show app version" }
cache-init = { cmd = "python -m tasks.cache_init", help = "Initialize records cache" }
esri-record = { cmd = "python -m tasks.record_esri", help = "Add Esri item distribution options to a record" }
esri-item = { cmd = "python -m tasks.esri_item", help = "Sync record details to an Esri item" }
clone-record = { cmd = "python -m tasks.record_clone", help = "Clone record from cache into import directory" }
issues-record = { cmd = "python -m tasks.record_issues", help = "Set GitLab issues for a record"}
admin-record = { cmd = "python -m tasks.record_dump_admin", help = "View administrative metadata for a record" }
restrict-record = { cmd = "python -m tasks.record_permissions", help = "Set access permissions for a record" }
select-records = { cmd = "python -m tasks.records_select", help = "Copy records from cache to import directory for editing" }
zap-records = { cmd = "python -m tasks.records_zap", help = "Process Zap ⚡️ authored records from import directory" }
ops-eo-records = { cmd = "python -m tasks.records_ops_eo", help = "Process Ops EO authored records from import directory" }
preview-records = { cmd = "python -m tasks.records_preview", help = "Preview records as HTML items" }
import-records = { cmd = "python -m tasks.records_import", help = "Import records from directory" }
build-records = { cmd = "python -m tasks.records_build", help = "Build records as a catalogue site" }
check-records = { cmd = "python -m tasks.records_check", help = "Check static site and records contents" }
invalidate-records = { cmd = "python -m tasks.records_invalidate", help = "Invalidate cached records in live site" }
upgrade-records = { cmd = "python -m tasks.records_upgrade_2026_04", help = "Upgrade records" }
bootstrap-records = { cmd = "python -m tasks.records_bootstrap", help = "Bootstrap a new records repo" }
workflow-testing = { cmd = "python -m tasks.records_workflow_testing", help = "Import records to testing site" }
workflow-live = { cmd = "python -m tasks.records_workflow_live", help = "Import records to live site" }
site-invalidate = { cmd = "python -m tasks.site_invalidate", help = "Invalidate cached content in live site" }
thumbnail-invalidate = { cmd = "python -m tasks.thumbnail_invalidate", help = "Invalidate cached item thumbnail in CDN" }
serve = { cmd = "python -m tasks.serve", help = "Serve local catalogue site" }
[tool.ruff]
src = ["src"]
line-length = 120
target-version = "py311"
[tool.ruff.lint]
# A | builtins (variables named after builtin names)
# ANN | annotations (type hints)
# B | bug-bear (bad code)
# B9 | bug-bear opinionated (additional bad code)
# C90 | mccabe (code complexity)
# C4 | comprehensions (list/dict/set comprehensions)
# D | pydocstyle (docstring)
# DTZ | datetimez (date/time)
# E | pycodestyle errors (PEP8)
# EM | errmsg (exceptions)
# ERA | eraticate (comments)
# F | pyflakes (invalid/bad code)
# FA | uture-annotations (type hints)
# I | isort (import ordering)
# N | pep8-naming (PEP8)
# PT | pytest-style (tests)
# PTH | use-pathlib (old syntax)
# RET | return (return statements)
# RUF | ruff (other)
# S | bandit (static security)
# SIM | simplicity (code complexity)
# TD | todos (comments)
# TRY | tryceratops (exceptions)
# UP | pyupgrade (old syntax)
# W | pycodestyle warnings (PEP8)
select = ["A", "ANN", "B", "B9", "C90", "C4", "D", "DTZ", "E", "EM", "ERA", "F", "FA", "I", "N", "PT", "PTH", "RET", "RUF", "S", "SIM", "TD", "TRY", "UP", "W"]
# D100 | for avoding module level docstrings
# D104 | for avoding package level docstrings
# D203 | for requring blank line before classes (which looks silly)
# D212 | for docstring requring multi-line comments to start on first line (which looks silly)
# D401 | for requring imperative mood in docstrings (finally had enough, too annoying)
# D402 | for docstring that can't resemble their signatures (despite them being completely different)
# D413 | for requiring a blankline in docstrings if a section is used (which looks silly)
# E501 | for bug-bear compatibility (as B905 overrides line length checks)
# PT001 | for `@pytest.fixture` parentheses (as it's unstable/unreliable)
# PT023 | for `@pytest.mark.cov` parentheses (as it's unstable/unreliable)
# TD002 | for TODOs without an author (as an issue should assign ownership)
ignore = [
"D100",
"D104",
"D107",
"D203",
"D212",
"D401",
"D402",
"E501",
"PT001",
"PT023",
"TD002",
"D413",
]
[tool.ruff.lint.per-file-ignores]
# config.py | D401 | ignore imperative mood in docstrings (too unreliable)
# config.py | N802 | ignore use of upper case method names
"config.py" = ["D401", "N802"]
# tailwind.py | N802 | ignore use of upper case method names in config subclass
"tasks/tailwind.py" = ["N802"]
# tests/* | ANN201 | ignore public functions
# tests/* | ANN401 | ignore use of 'Any' type
# tests/* | S101 | ignore use of assert
"tests/*" = ["ANN201", "ANN401", "D401", "S101"]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
[tool.ty.src]
include = ["src", "tasks"]
exclude = ["tests"]
[tool.pymarkdown]
plugins.md013.line_length = 120
plugins.md013.code_blocks = false
plugins.md014.enabled = false
extensions.markdown-extended-autolinks.enabled = true
[tool.pytest_env]
# `X_ADMIN_METADATA_SIGNING_KEY_PRIVATE` is needed to sign administrative metadata in test records but is not real key
LANTERN_LOG_LEVEL = "INFO"
LANTERN_PARALLEL_JOBS = "1"
LANTERN_ENABLE_FEATURE_SENTRY = "false"
LANTERN_SENTRY_ENVIRONMENT = "test"
LANTERN_ADMIN_METADATA_ENCRYPTION_KEY_PRIVATE = "{\"kty\":\"EC\",\"kid\":\"bas_metadata_testing_encryption_key\",\"alg\":\"ECDH-ES+A128KW\",\"crv\":\"P-256\",\"x\":\"kYiwq6MW8lGN6PB2csVMuMRcISVk5eNUpGkjM-mm8QY\",\"y\":\"raOTT2xAQhHFKhPHy338L8Ql0hvgsDtHwtEc8pCOf2Q\",\"d\":\"2lBuUtJK2TcV_b4B-bDCPnRVAqMnYvnLZ41IUguprs8\"}"
LANTERN_ADMIN_METADATA_SIGNING_KEY_PUBLIC = "{\"kty\":\"EC\",\"kid\":\"bas_metadata_testing_signing_key\",\"alg\":\"ES256\",\"crv\":\"P-256\",\"x\":\"FzxBM1ZPO5W2bYlhT9AjZUKz5_oH5vIh4_k4aEZ64rM\",\"y\":\"vmK5PWOoIA9eO0ntLh37AMpVODyj0NWf842FwoN-GRs\"}"
LANTERN_STORE_GITLAB_ENDPOINT = "https://gitlab.example.com"
LANTERN_STORE_GITLAB_TOKEN = "x"
LANTERN_STORE_GITLAB_PROJECT_ID = "1234"
LANTERN_STORE_GITLAB_DEFAULT_BRANCH = "main"
LANTERN_STORE_GITLAB_CACHE_PATH = "cache"
LANTERN_TEMPLATES_PLAUSIBLE_ID = "x"
LANTERN_TEMPLATES_ITEM_CONTACT_ENDPOINT = "https://example.com/contact" # must be "https://example.com/contact"
LANTERN_TEMPLATES_ITEM_CONTACT_TURNSTILE_KEY = "x"
LANTERN_TEMPLATES_ITEM_VERSIONS_ENDPOINT = "https://example.com"
LANTERN_SITE_UNTRUSTED_S3_ACCESS_ID = "x"
LANTERN_SITE_UNTRUSTED_S3_ACCESS_SECRET = "x"
LANTERN_SITE_UNTRUSTED_S3_BUCKET_TESTING = "x"
LANTERN_SITE_UNTRUSTED_S3_BUCKET_LIVE = "x"
LANTERN_SITE_TRUSTED_RSYNC_HOST = "x"
LANTERN_SITE_TRUSTED_RSYNC_BASE_PATH_TESTING = "x"
LANTERN_SITE_TRUSTED_RSYNC_BASE_PATH_LIVE = "x"
LANTERN_VERIFY_SHAREPOINT_PROXY_ENDPOINT = "https://example.com"
LANTERN_VERIFY_SAN_PROXY_ENDPOINT = "https://example.com"
LANTERN_BASE_URL_TESTING = "https://example.com"
LANTERN_BASE_URL_LIVE = "https://example.com"
X_ADMIN_METADATA_SIGNING_KEY_PRIVATE = "{\"kty\":\"EC\",\"kid\":\"bas_metadata_testing_signing_key\",\"alg\":\"ES256\",\"crv\":\"P-256\",\"x\":\"FzxBM1ZPO5W2bYlhT9AjZUKz5_oH5vIh4_k4aEZ64rM\",\"y\":\"vmK5PWOoIA9eO0ntLh37AMpVODyj0NWf842FwoN-GRs\",\"d\":\"2lBuUtJK2TcV_b4B-bDCPnRVAqMnYvnLZ41IUguprs8\"}"
[tool.pytest.ini_options]
# --strict-markers | fail if unknown markers are used
# --random-order | run tests in random order
# -x | stop after first failure [Overriden in CI]
# --ff | run failed tests first
# -n auto | run tests in parallel using all available CPUs
addopts = "--strict-markers --random-order -x --ff -n auto"
markers = [
"cov: coverage checks (deselect with '-m \"not cov\"')",
]
[tool.coverage.report]
skip_empty = true
show_missing = false
fail_under = 100
exclude_lines = [
"pragma: no cover",
"@abstractmethod",
]
[tool.coverage.html]
directory = "htmlcov"
[tool.coverage.run]
branch = true
source = ["src"]
omit = []
[build-system]
requires = ["uv_build>=0.9.18,<0.12.0"]
build-backend = "uv_build"