Skip to content

Commit d37cbe4

Browse files
committed
feat: Migrate to uv.
1 parent 8f2a7ca commit d37cbe4

File tree

13 files changed

+1469
-1400
lines changed

13 files changed

+1469
-1400
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
{
22
"name": "openapi-pydantic",
33
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
4+
"mounts": [
5+
"source=${devcontainerId}-cache,target=${containerWorkspaceFolder}/.cache,type=volume",
6+
"source=${devcontainerId}-venv,target=${containerWorkspaceFolder}/.venv,type=volume"
7+
],
8+
"onCreateCommand": "sudo chown vscode .cache && sudo chown vscode .venv",
49
"features": {
5-
"ghcr.io/devcontainers-contrib/features/poetry:2": {
6-
"version": "latest"
10+
"ghcr.io/va-h/devcontainers-features/uv:1": {
11+
"version": "latest",
12+
"shellautocompletion": true
713
}
814
},
915
"containerEnv": {
10-
"POETRY_VIRTUALENVS_IN_PROJECT": "true"
16+
"XDG_CACHE_DIR": ".cache",
17+
"UV_CACHE_DIR": ".cache/.uv-cache",
18+
"UV_LINK_MODE": "symlink",
19+
"RUFF_CACHE_DIR": ".cache/.ruff-cache",
20+
"MYPY_CACHE_DIR": ".cache/.mypy-cache"
1121
},
12-
"postCreateCommand": "poetry install && pip install --upgrade tox",
22+
"updateContentCommand": "uv sync --all-groups",
1323
"customizations": {
1424
"vscode": {
1525
"extensions": [
1626
"ms-python.python",
1727
"ms-python.vscode-pylance",
18-
"charliermarsh.ruff"
28+
"charliermarsh.ruff",
29+
"github.vscode-github-actions"
1930
]
2031
}
2132
}

.github/workflows/publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
steps:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v5
18+
with:
19+
version: "0.7.5"
20+
enable-cache: true
1621
- name: Set up Python
1722
uses: actions/setup-python@v5
1823
with:
1924
python-version: 3.12
20-
- name: Install Poetry
21-
uses: snok/install-poetry@v1
22-
with:
23-
virtualenvs-create: false
24-
version: 1.8.3
2525
- name: Build package distribution
26-
run: poetry build
26+
run: uv build
2727
- name: Upload package artifact
2828
uses: actions/upload-artifact@v4
2929
with:
@@ -38,7 +38,7 @@ jobs:
3838
name: test
3939
url: https://test.pypi.org/p/openapi-pydantic
4040
permissions:
41-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
41+
id-token: write
4242
steps:
4343
- name: Download package distribution
4444
uses: actions/download-artifact@v4
@@ -58,7 +58,7 @@ jobs:
5858
name: production
5959
url: https://pypi.org/p/openapi-pydantic
6060
permissions:
61-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
61+
id-token: write
6262
steps:
6363
- name: Download package distribution
6464
uses: actions/download-artifact@v4

.github/workflows/test.yml

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,101 @@ on:
77
pull_request:
88
types: [opened, synchronize, reopened]
99

10+
11+
env:
12+
UV_SYSTEM_PYTHON: 1
13+
UV_VERSION: 0.7.5
14+
1015
jobs:
11-
tox:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v5
22+
with:
23+
version: "$UV_VERSION"
24+
enable-cache: true
25+
- name: Set up Python 3.12
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: '3.12'
29+
- name: Install the project
30+
run: uv sync --locked --all-extras --group dev
31+
- name: Lint
32+
run:
33+
mypy openapi_pydantic tests
34+
ruff check openapi_pydantic tests
35+
ruff format openapi_pydantic tests --check
36+
37+
test:
1238
runs-on: ubuntu-latest
1339
strategy:
1440
matrix:
15-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
41+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
42+
pydantic-version: ['pydantic-v1', 'pydantic-v2']
43+
fail-fast: false
1644
steps:
1745
- uses: actions/checkout@v4
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
with:
49+
version: "$UV_VERSION"
50+
enable-cache: true
1851
- name: Set up Python ${{ matrix.python-version }}
1952
uses: actions/setup-python@v5
2053
with:
2154
python-version: ${{ matrix.python-version }}
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
python -m pip install tox tox-gh-actions
26-
- name: Install Poetry
27-
uses: snok/install-poetry@v1
55+
- name: Install the project
56+
run: uv sync --locked --all-extras --group test
57+
- name: Install Pydantic v1
58+
if: matrix.pydantic-version == 'pydantic-v1'
59+
run: uv pip install "pydantic>=1.10.0,<2.0.0"
60+
- name: Install Pydantic v2
61+
if: matrix.pydantic-version == 'pydantic-v2'
62+
run: uv pip install --upgrade "pydantic>=2.0.2,<3.0.0"
63+
- run: mkdir coverage
64+
- name: Test
65+
run: coverage run -m pytest tests
66+
env:
67+
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
68+
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
69+
- name: Store coverage files
70+
uses: actions/upload-artifact@v4
2871
with:
29-
version: 1.8.3
30-
virtualenvs-create: true
31-
virtualenvs-in-project: true
32-
- name: Run tox test suite
33-
run: tox
72+
name: coverage-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
73+
path: coverage
74+
include-hidden-files: true
75+
76+
77+
coverage:
78+
needs: [test]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/checkout@v4
82+
- uses: actions/setup-python@v5
83+
with:
84+
python-version: '3.12'
85+
- name: Install uv
86+
uses: astral-sh/setup-uv@v5
87+
with:
88+
version: "$UV_VERSION"
89+
enable-cache: true
90+
- name: Install Dependencies
91+
run: uv pip install coverage
92+
- name: Get coverage files
93+
uses: actions/download-artifact@v4
94+
with:
95+
pattern: coverage-*
96+
path: coverage
97+
merge-multiple: true
98+
- run: ls -la coverage
99+
- run: coverage combine coverage
100+
- run: coverage report
101+
- run: coverage html --title "Coverage for ${{ github.sha }}"
102+
- name: Store coverage HTML
103+
uses: actions/upload-artifact@v4
104+
with:
105+
name: coverage-html
106+
path: htmlcov
107+
include-hidden-files: true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ __pycache__
33
/.mypy_cache
44
/.pytest_cache
55
/.ruff_cache
6-
/.tox
6+
/.uv_cache
7+
/.cache
78
/.venv
89
/*.egg-info
910
/build

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"source.fixAll": "explicit",
1212
"source.organizeImports": "explicit"
1313
},
14-
"editor.defaultFormatter": "charliermarsh.ruff"
14+
"editor.defaultFormatter": "charliermarsh.ruff",
15+
"[toml]": {
16+
"editor.defaultFormatter": "tamasfe.even-better-toml"
17+
}
1518
}

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ time by ensuring that your changes will be accepted with fewer revisions down th
1616

1717
### Local Development
1818

19-
A [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) configuration is provided in the repo to get your environment setup automatically. Alternatively you can install [tox](https://tox.wiki/en/latest/) and [poetry](https://python-poetry.org/) manually.
19+
A [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) configuration is provided in the repo to get your environment setup automatically.
20+
21+
If devcontainers aren't your speed, you can manually setup your environment by installing `uv` and
22+
then running `uv sync --all-groups`.
2023

2124
### Testing
2225

23-
Please ensure all changes have good test coverage and are formatted correctly. You can run the test
24-
suite and linters using [tox](https://tox.wiki/en/latest/) - just run `tox` from the root of this
25-
repo to run the checks. These will also be run automatically in CI once your PR is opened. Don't
26-
worry about testing against every Python version - the CI action will do this for you!
26+
Please ensure all changes have good test coverage. We use [pytest](https://docs.pytest.org/en/latest/) for testing, and [coverage](https://coverage.readthedocs.io/en/latest/) for measuring code coverage.
2727

2828
### Tagging
2929

openapi_pydantic/v3/v3_0/encoding.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"contentType": "image/png, image/jpeg",
1515
"headers": {
1616
"X-Rate-Limit-Limit": {
17-
"description": "The number of allowed requests in the "
18-
"current period",
17+
"description": "The number of allowed requests in the current period",
1918
"schema": {"type": "integer"},
2019
}
2120
},

openapi_pydantic/v3/v3_1/encoding.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"contentType": "image/png, image/jpeg",
1515
"headers": {
1616
"X-Rate-Limit-Limit": {
17-
"description": "The number of allowed requests in the "
18-
"current period",
17+
"description": "The number of allowed requests in the current period",
1918
"schema": {"type": "integer"},
2019
}
2120
},

openapi_pydantic/v3/v3_1/response.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@
3030
"content": {"text/plain": {"schema": {"type": "string", "example": "whoa!"}}},
3131
"headers": {
3232
"X-Rate-Limit-Limit": {
33-
"description": "The number of allowed requests in the "
34-
"current period",
33+
"description": "The number of allowed requests in the current period",
3534
"schema": {"type": "integer"},
3635
},
3736
"X-Rate-Limit-Remaining": {
38-
"description": "The number of remaining requests in the "
39-
"current period",
37+
"description": "The number of remaining requests in the current period",
4038
"schema": {"type": "integer"},
4139
},
4240
"X-Rate-Limit-Reset": {

0 commit comments

Comments
 (0)