Skip to content

Commit 3afc1de

Browse files
authored
Merge pull request #15 from seapagan/convert-to-uv
migrate fully to 'uv' from 'poetry'
2 parents efe7389 + 1477281 commit 3afc1de

15 files changed

+2357
-2918
lines changed

.github/dependabot.yml

-13
This file was deleted.

.github/renovate.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"labels": [
7+
"dependencies"
8+
],
9+
"gitIgnoredAuthors": [
10+
"66853113+pre-commit-ci[bot]@users.noreply.github.com"
11+
],
12+
"enabled": true,
13+
"enabledManagers": [
14+
"pep621",
15+
"github-actions"
16+
],
17+
"ignoreDeps": []
18+
}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,5 @@ cython_debug/
209209
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
210210
test.db
211211
.python-version
212+
.changelog_generator.toml
213+
.envrc

.pre-commit-config.yaml

+31-48
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ci:
2-
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks [dependabot skip]"
2+
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.5.0
5+
rev: v5.0.0
66
hooks:
77
- id: check-yaml
88
args: [--unsafe]
@@ -11,67 +11,50 @@ repos:
1111
- id: check-merge-conflict
1212
- id: end-of-file-fixer
1313

14+
# - repo: https://github.com/renovatebot/pre-commit-hooks
15+
# rev: 39.69.2
16+
# hooks:
17+
# - id: renovate-config-validator
18+
# files: ^renovate\.json$
19+
1420
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.1.14
21+
rev: v0.11.2
1622
hooks:
1723
- id: ruff
24+
args: ["--output-format=concise"]
1825
name: "lint with ruff"
1926
- id: ruff-format
2027
name: "format with ruff"
2128

22-
- repo: https://github.com/jackdewinter/pymarkdown
23-
rev: 0.9.16
24-
hooks:
25-
- id: pymarkdown
26-
name: "check markdown"
27-
exclude: ^.github/|CHANGELOG
28-
args: [-d, "MD046", scan]
29-
3029
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: "v1.8.0" # Use the sha / tag you want to point at
30+
rev: "v1.15.0" # Use the sha / tag you want to point at
3231
hooks:
3332
- id: mypy
34-
name: "Check with Mypy"
35-
36-
- repo: https://github.com/RobertCraigie/pyright-python
37-
rev: v1.1.349
38-
hooks:
39-
- id: pyright
40-
name: "Check with Pyright"
41-
exclude: tests
42-
additional_dependencies: [sqlalchemy, uvicorn, fastapi]
43-
44-
- repo: https://github.com/python-poetry/poetry
45-
rev: "1.7.0"
46-
hooks:
47-
- id: poetry-check
48-
name: "check poetry files"
49-
# - id: poetry-lock
33+
name: "run mypy"
34+
additional_dependencies:
35+
- pydantic
36+
- sqladmin
5037

51-
- repo: https://github.com/python-poetry/poetry-plugin-export
52-
rev: "1.6.0"
38+
- repo: https://github.com/astral-sh/uv-pre-commit
39+
# uv version.
40+
rev: 0.6.9
5341
hooks:
54-
- id: poetry-export
55-
name: "export production dependencies"
42+
# Update the uv lockfile
43+
- id: uv-lock
44+
- id: uv-export
45+
name: "Export dependencies to 'requirements.txt'"
5646
args:
5747
[
58-
"--without-hashes",
59-
"-f",
60-
"requirements.txt",
61-
"-o",
62-
"requirements.txt",
63-
"--without",
64-
"dev",
48+
"--no-hashes",
49+
"--no-dev",
50+
"--no-emit-project",
51+
"--output-file=requirements.txt",
6552
]
66-
- id: poetry-export
67-
name: "export development dependencies"
53+
- id: uv-export
54+
name: "Export dev dependencies to 'requirements-dev.txt'"
6855
args:
6956
[
70-
"--without-hashes",
71-
"-f",
72-
"requirements.txt",
73-
"-o",
74-
"requirements-dev.txt",
75-
"--with",
76-
"dev",
57+
"--no-hashes",
58+
"--no-emit-project",
59+
"--output-file=requirements-dev.txt",
7760
]

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023-2024 Grant Ramsay
3+
Copyright (c) 2023-2025 Grant Ramsay
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,19 @@ SQLAlchemy 2.0.
2727
## Installation
2828

2929
Clone the repository and install the dependencies. This project uses
30-
[Poetry](https://python-poetry.org/) for dependency management which should be
30+
[uv](https://docs.astral.sh/uv/) for dependency management which should be
3131
installed on your system first.
3232

33+
Install the project dependencies:
34+
3335
```console
34-
poetry install
36+
uv sync
3537
```
3638

3739
Then switch to the virtual environment:
3840

3941
```console
40-
poetry shell
42+
source .venv/bin/activate
4143
```
4244

4345
## Usage
@@ -109,7 +111,7 @@ This project is licensed under the terms of the MIT license.
109111
```pre
110112
MIT License
111113
112-
Copyright (c) 2023-2024 Grant Ramsay
114+
Copyright (c) 2023-2025 Grant Ramsay
113115
114116
Permission is hereby granted, free of charge, to any person obtaining a copy
115117
of this software and associated documentation files (the "Software"), to deal

db.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Set up the database connection and session.""" ""
2+
23
from collections.abc import AsyncGenerator
34
from typing import Any
45

main.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""An example of using FastAPI with Async SQLAlchemy 2."""
2+
23
from collections.abc import AsyncGenerator, Sequence
34
from contextlib import asynccontextmanager
4-
from typing import Any
5+
from typing import Annotated, Any
56

67
import uvicorn
78
from db import get_db, init_models
@@ -30,7 +31,7 @@ async def root() -> dict[str, str]:
3031

3132
@app.post("/users/", response_model=UserResponseModel)
3233
async def create_user(
33-
name: str, email: str, session: AsyncSession = Depends(get_db)
34+
name: str, email: str, session: Annotated[AsyncSession, Depends(get_db)]
3435
) -> User:
3536
"""Add a user."""
3637
user = User(name=name, email=email)
@@ -39,7 +40,9 @@ async def create_user(
3940

4041

4142
@app.get("/users/", response_model=Sequence[UserResponseModel])
42-
async def get_users(session: AsyncSession = Depends(get_db)) -> Sequence[User]:
43+
async def get_users(
44+
session: Annotated[AsyncSession, Depends(get_db)],
45+
) -> Sequence[User]:
4346
"""Get all users."""
4447
result = await session.execute(select(User))
4548
return result.scalars().all()

models.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Define Models used in this example."""
2+
23
from db import Base
34
from sqlalchemy import String
45
from sqlalchemy.orm import Mapped, mapped_column

0 commit comments

Comments
 (0)