Skip to content

Commit 9bd2d94

Browse files
authored
Switch to Litestar and add UV along the way
Signed-off-by: GitHub <[email protected]>
1 parent 8fe972d commit 9bd2d94

26 files changed

+2495
-559
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-case-conflict
66
- id: check-merge-conflict
@@ -12,3 +12,23 @@ repos:
1212
- id: mixed-line-ending
1313
args: [ --fix=lf ]
1414
- id: end-of-file-fixer
15+
exclude: .devcontainer/devcontainer-lock.json
16+
17+
- repo: https://github.com/astral-sh/uv-pre-commit
18+
rev: 0.5.4
19+
hooks:
20+
- id: uv-lock
21+
- id: uv-export
22+
args:
23+
- --frozen
24+
- --no-emit-project
25+
- --output-file=requirements.txt
26+
files: pyproject.toml|uv.lock
27+
- id: uv-export
28+
args:
29+
- --frozen
30+
- --no-emit-project
31+
- --all-extras
32+
- --all-groups
33+
- --output-file=requirements-dependabot.txt
34+
files: pyproject.toml|uv.lock

Containerfile renamed to Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12-slim@sha256:43a49c9cc2e614468e3d1a903aabe17a97a4c788c76cf5337b5cdc3535b07d4f
1+
FROM python:3.13-slim@sha256:751d8bece269ba9e672b3f2226050e7e6fb3f3da3408b5dcb5d415a054fcb061
22

33
# Define Git SHA build argument for sentry
44
ARG git_sha="development"

docs/source/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def linkcode_resolve(domain: str, info: dict) -> str:
6060
if not info["module"]:
6161
return None
6262

63-
import importlib # noqa: PLC0415
64-
import inspect # noqa: PLC0415
65-
import types # noqa: PLC0415
63+
import importlib
64+
import inspect
65+
import types
6666

6767
mod = importlib.import_module(info["module"])
6868

make.ps1

Lines changed: 0 additions & 126 deletions
This file was deleted.

noxfile.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""Noxfile."""
2+
3+
import shutil
4+
from pathlib import Path
5+
6+
import nox
7+
8+
nox.options.default_venv_backend = "none"
9+
nox.options.sessions = ["lints"]
10+
11+
12+
CLEANABLE_TARGETS = [
13+
"./dist",
14+
"./build",
15+
"./.nox",
16+
"./.coverage",
17+
"./.coverage.*",
18+
"./coverage.json",
19+
"./**/.mypy_cache",
20+
"./**/.pytest_cache",
21+
"./**/__pycache__",
22+
"./**/*.pyc",
23+
"./**/*.pyo",
24+
]
25+
26+
27+
@nox.session
28+
def tests(session: nox.Session) -> None:
29+
"""Run tests."""
30+
session.run("pytest")
31+
32+
33+
@nox.session
34+
def lints(session: nox.Session) -> None:
35+
"""Run lints."""
36+
session.run("pre-commit", "run", "--all-files")
37+
session.run("ruff", "format", ".")
38+
session.run("ruff", "check", "--fix", ".")
39+
session.run("mypy", "--strict", "src/")
40+
41+
42+
@nox.session
43+
def clean(_: nox.Session) -> None:
44+
"""Clean cache, .pyc, .pyo, and test/build artifact files from project."""
45+
count = 0
46+
for searchpath in CLEANABLE_TARGETS:
47+
for filepath in Path().glob(searchpath):
48+
if filepath.is_dir():
49+
shutil.rmtree(filepath)
50+
else:
51+
filepath.unlink()
52+
count += 1

pyproject.toml

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,75 @@
11
[project]
22
name = "api.letsbuilda.dev"
33
description = "Public API for our projects"
4-
authors = [
5-
{ name = "Bradley Reynolds", email = "[email protected]" },
6-
]
4+
authors = [{ name = "Bradley Reynolds", email = "[email protected]" }]
75
license = { text = "MIT" }
86
readme = "README.md"
9-
requires-python = ">=3.11,<3.13"
10-
dynamic = ["version", "dependencies", "optional-dependencies"]
7+
requires-python = ">=3.12"
8+
dynamic = ["version"]
9+
dependencies = [
10+
# Core
11+
## Metrics
12+
"sentry-sdk>=2.10.0",
13+
## Settings and configuration
14+
"pydantic>=2.10.1",
15+
"pydantic-settings>=2.6.1",
16+
## Web
17+
"gunicorn>=23.0.0",
18+
"uvicorn-worker>=0.2.0",
19+
"uvicorn[standard]>=0.30.3",
20+
"litestar[brotli]>=2.10.0",
21+
"imsosorry>=1.2.1",
22+
]
1123

1224
[project.urls]
1325
repository = "https://github.com/letsbuilda/api.letsbuilda.dev/"
1426
documentation = "https://docs.letsbuilda.dev/api.letsbuilda.dev/"
1527

28+
[project.optional-dependencies]
29+
docs = [
30+
"sphinx>=7.4.4",
31+
"furo>=2024.5.6",
32+
"sphinx-autoapi>=3.1.2",
33+
"releases>=2.1.1",
34+
]
35+
36+
[dependency-groups]
37+
dev = [
38+
# DX
39+
"nox>=2024.4.15",
40+
"pre-commit>=3.7.1",
41+
# Linters
42+
"ruff>=0.5.2",
43+
"mypy>=1.10.1",
44+
]
45+
tests = ["pytest>=8.2.2", "pytest-randomly>=3.15.0", "coverage>=7.6.1"]
46+
1647
[build-system]
1748
requires = ["setuptools", "wheel"]
1849
build-backend = "setuptools.build_meta"
1950

2051
[tool.setuptools.dynamic.version]
2152
attr = "api.__version__"
2253

23-
[tool.setuptools.dynamic.dependencies]
24-
file = ["requirements/requirements.txt"]
25-
26-
[tool.setuptools.dynamic.optional-dependencies]
27-
dev = { file = ["requirements/requirements-dev.txt"] }
28-
tests = { file = ["requirements/requirements-tests.txt"] }
29-
docs = { file = ["requirements/requirements-docs.txt"] }
30-
3154
[tool.ruff]
32-
preview = true
33-
unsafe-fixes = true
34-
target-version = "py311"
35-
select = ["ALL"]
55+
target-version = "py313"
3656
line-length = 120
57+
58+
[tool.ruff.lint]
59+
select = ["ALL"]
3760
ignore = [
3861
"CPY001", # (Missing copyright notice at top of file) - No license
39-
"S311", # (Standard pseudo-random generators are not suitable for cryptographic purposes) - Not a crypto lib
62+
"S311", # (Standard pseudo-random generators are not suitable for cryptographic purposes) - Not a crypto lib
4063
]
4164

42-
[tool.ruff.extend-per-file-ignores]
65+
[tool.ruff.lint.extend-per-file-ignores]
4366
"docs/*" = [
4467
"INP001", # (File `tests/*.py` is part of an implicit namespace package. Add an `__init__.py`.) - Docs are not modules
4568
]
4669
"tests/*" = [
4770
"INP001", # (File `tests/*.py` is part of an implicit namespace package. Add an `__init__.py`.) - Tests are not modules
48-
"S101", # (Use of `assert` detected) - Yes, that's the point
71+
"S101", # (Use of `assert` detected) - Yes, that's the point
4972
]
5073

51-
[tool.ruff.pydocstyle]
74+
[tool.ruff.lint.pydocstyle]
5275
convention = "numpy"

0 commit comments

Comments
 (0)