Skip to content

Commit 2111877

Browse files
authored
migrate to uv (#24)
1 parent c092d4e commit 2111877

7 files changed

Lines changed: 880 additions & 1563 deletions

File tree

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude = venv,.venv,build,dist,__pycache__,.pytest_cache,.mypy_cache,*.egg-info
3+
max-line-length = 127
4+
max-complexity = 10
5+
inline-quotes = double
6+
count = True
7+
show-source = True
8+
statistics = True

.github/workflows/python-app.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,26 @@ jobs:
2121
runs-on: ubuntu-22.04
2222

2323
steps:
24-
- uses: actions/checkout@v3
25-
- name: Set up Python 3.12
26-
uses: actions/setup-python@v3
24+
- uses: actions/checkout@v4
25+
- name: Set up Python
26+
uses: actions/setup-python@v6
2727
with:
28-
python-version: "3.12"
28+
python-version-file: ".python-version"
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v7
31+
with:
32+
# Install a specific version of uv.
33+
version: "0.9.18"
34+
enable-cache: true
2935
- name: Install dependencies
3036
run: |
31-
pip install --user pipx
32-
python3 -m pipx ensurepath
33-
pipx install poetry
34-
poetry install
35-
- name: Lint with flake8
36-
run: |
37-
# stop the build if there are Python syntax errors or undefined names
38-
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
39-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --inline-quotes='double' --statistics
41-
- name: Run mypy
37+
uv sync --locked --all-extras --dev
38+
- name: Lint with flake8 and run mypy
4239
run: |
43-
poetry run mypy --strict .
40+
uv run poe lint
4441
- name: Test with pytest
4542
run: |
46-
poetry run coverage run --source=pyfastapi -m pytest
47-
poetry run coverage xml -o coverage.xml
43+
uv run poe coverage
4844
- name: Test coverage report
4945
uses: orgoro/coverage@v3.1
5046
if: ${{ github.event_name == 'pull_request' }}

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.12

poetry.lock

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

pyfastapi/repositories/person.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from .base import BaseRepository, extract_sort, extract_query
99

1010

11-
1211
class PersonRepository(BaseRepository):
1312
def get_person(self, id_: int) -> Person | None:
1413
stmt = select(Person, Country).join(Country, Person.country_code == Country.code).where(Person.id == id_)

pyproject.toml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
1-
[tool.poetry]
1+
[project]
22
name = "pyfastapi"
33
version = "0.1.0"
44
description = ""
5-
authors = ["Heinrich Chan <guiltyrage10@gmail.com>"]
5+
authors = [{ name = "Heinrich Chan", email = "guiltyrage10@gmail.com" }]
6+
requires-python = ">=3.12,<4"
67
readme = "README.md"
8+
dependencies = [
9+
"fastapi[all]>=0.109.0,<0.110",
10+
"fastapi-pagination>=0.12.14,<0.13",
11+
"sqlalchemy>=2.0.25,<3",
12+
"alembic>=1.13.1,<2",
13+
"toolz>=0.12.1,<0.13",
14+
]
715

8-
[tool.poetry.dependencies]
9-
python = "^3.12"
10-
fastapi = {extras = ["all"], version = "^0.109.0"}
11-
fastapi-pagination = "^0.12.14"
12-
sqlalchemy = "^2.0.25"
13-
alembic = "^1.13.1"
14-
toolz = "^0.12.1"
16+
[dependency-groups]
17+
dev = [
18+
"pytest>=8.0.0,<9",
19+
"flake8>=7.0.0,<8",
20+
"faker>=22.6.0,<23",
21+
"coverage>=7.4.1,<8",
22+
"mypy>=1.8.0,<2",
23+
"flake8-quotes>=3.4.0,<4",
24+
"poethepoet>=0.39.0",
25+
]
1526

27+
[build-system]
28+
requires = ["hatchling"]
29+
build-backend = "hatchling.build"
1630

17-
[tool.poetry.group.dev.dependencies]
18-
pytest = "^8.0.0"
19-
flake8 = "^7.0.0"
20-
faker = "^22.6.0"
21-
coverage = "^7.4.1"
22-
mypy = "^1.8.0"
23-
flake8-quotes = "^3.4.0"
31+
[tool.mypy]
32+
exclude = [
33+
"venv/",
34+
".venv/",
35+
"build/",
36+
"dist/",
37+
".pytest_cache/",
38+
".mypy_cache/",
39+
"htmlcov/",
40+
]
2441

25-
[build-system]
26-
requires = ["poetry-core"]
27-
build-backend = "poetry.core.masonry.api"
42+
[tool.poe.tasks.coverage]
43+
shell = "coverage run -m pytest && coverage report && coverage xml -o coverage.xml"
44+
45+
[tool.poe.tasks.flake8]
46+
shell = "flake8 ."
47+
48+
[tool.poe.tasks.mypy]
49+
shell = "mypy --strict ."
50+
51+
[tool.poe.tasks.lint]
52+
sequence = ["flake8", "mypy"]

0 commit comments

Comments
 (0)