Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ jobs:
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
# Keep in sync with `Dockerfile`'s `builder`.
version: "0.5.6"
# Keep in sync with pyproject.toml's `tool.uv.required-version`.
version: "0.8.13"
# Keep in sync with pyproject.toml's `project.requires-python`.
- run: uv python install 3.10
- run: uv sync --locked
- run: uv run -m skeleton
- run: uv run ruff format --check
- run: uv run ruff check
- run: uv run mypy
- run: uv run ty check
- run: uv run pytest
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"astral-sh.ty",
"charliermarsh.ruff",
"ms-python.python",
"tamasfe.even-better-toml"
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Inspired from https://github.com/astral-sh/uv-docker-example/blob/dee88a8c43be3b16b0ad58f0daee5eaee7e2157a/multistage.Dockerfile.

# Keep in sync with `.github/workflows/test.yml`.
FROM ghcr.io/astral-sh/uv:0.5.6-python3.10-bookworm-slim AS builder
# Keep uv version in sync with pyproject.toml's `tool.uv.required-version`.
# Keep Python version in sync with:
# - pyproject.toml's `project.requires-python`.
# - the main stage below.
FROM ghcr.io/astral-sh/uv:0.8.13-python3.10-bookworm-slim AS builder

ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy

Expand All @@ -17,7 +20,7 @@ RUN --mount=type=bind,source=skeleton,target=skeleton_tmp \
mv app/skeleton skeleton && \
rm -r app

# Keep this synced with the builder image.
# Keep this synced with the `builder` stage above.
FROM python:3.10-slim-bookworm

COPY --from=builder /venv app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ On top of the `atoti` package, it comes with:
- Dependency management with [uv](https://docs.astral.sh/uv)
- Config management with [Pydantic](https://docs.pydantic.dev/2.6/concepts/pydantic_settings)
- Testing with [pytest](https://docs.pytest.org)
- Type checking with [mypy](http://mypy-lang.org)
- Type checking with [ty](https://docs.astral.sh/ty)
- Formatting and linting with [Ruff](https://docs.astral.sh/ruff)
- Continuous testing with [GitHub Actions](https://github.com/features/actions)

Expand Down
2 changes: 1 addition & 1 deletion app/load_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def read_station_details(
http_client=http_client,
),
)["data"]["stations"]
station_information_df = pd.DataFrame(stations_data)[
station_information_df = pd.DataFrame(stations_data)[ # ty: ignore[no-matching-overload]
["station_id", "name", "capacity", "lat", "lon"]
].rename(
columns={
Expand Down
2 changes: 1 addition & 1 deletion app/util/reverse_geocode.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _reverse_geocode(

results_df = results_df.set_index(list(coordinates_df.columns))
results_df = results_df.rename(columns=_COLUMN_NAME_MAPPING)
return results_df.to_dict("index") # type: ignore[return-value]
return results_df.to_dict("index")


def reverse_geocode(
Expand Down
37 changes: 17 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[dependency-groups]
dev = [
"docker",
"mypy",
"pandas-stubs",
"pytest",
"pytest-asyncio",
"ruff",
]
dev = ["docker", "pandas-stubs", "pytest", "pytest-asyncio", "ruff", "ty"]

[project]
name = "app"
version = "0.1.0"
# Keep in sync with:
# - .github/workflows/test.yml
# - Dockerfile`'s `FROM` commands.
requires-python = ">=3.10"
dependencies = [
"atoti[jdbc]",
Expand All @@ -22,17 +18,6 @@ dependencies = [
]


[tool.mypy]
files = "app,skeleton,tests" # Remove once https://github.com/python/mypy/issues/10428 is fixed.
strict = true
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = ["docker", "docker.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
addopts = "--doctest-modules --strict-markers"
asyncio_default_fixture_loop_scope = "session"
Expand Down Expand Up @@ -71,8 +56,20 @@ select = ["ALL"]
banned-from = ["atoti", "pandas"]

[tool.ruff.lint.flake8-import-conventions.aliases]
atoti = "tt"
atoti = "tt"
pandas = "pd"

[tool.ruff.lint.isort]
combine-as-imports = true

[tool.ty.rules]
unused-ignore-comment = "warn"

[tool.ty.terminal]
error-on-warning = true

[tool.uv]
# Keep in sync with:
# - .github/workflows/test.yml
# - Dockerfile`'s `builder`.
required-version = ">=0.8.13"
7 changes: 5 additions & 2 deletions tests/docker/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ def docker_bin_fixture() -> Path:


@pytest.fixture(name="docker_client", scope="session")
def docker_client_fixture() -> docker.DockerClient:
return docker.from_env()
def docker_client_fixture() -> Generator[docker.DockerClient, None, None]:
client = docker.from_env()
yield client
client.close()


@pytest.fixture(name="docker_image_name", scope="session")
Expand Down Expand Up @@ -76,3 +78,4 @@ def session_inside_docker_container_fixture(
)
session = tt.Session.connect(f"http://localhost:{host_port}")
yield session
logs.close()
Loading
Loading