Skip to content

Commit c186a3a

Browse files
committed
chore: migrate to uv
1 parent 692e86a commit c186a3a

13 files changed

+648
-591
lines changed

.devcontainer/devcontainer.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "Python",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"ghcr.io/devcontainers/features/python:1": {
6+
"version": "latest",
7+
"installTools": false,
8+
"installJupyterlab": false,
9+
"toolsToInstall": "mypy"
10+
},
11+
"ghcr.io/va-h/devcontainers-features/uv:1": {},
12+
"ghcr.io/devcontainers-contrib/features/shfmt:1": {},
13+
"ghcr.io/dhoeric/features/hadolint:1": {},
14+
"ghcr.io/michidk/devcontainers-features/typos:1": {},
15+
"ghcr.io/devcontainers/features/common-utils:2": {
16+
"configureZshAsDefaultShell": true
17+
}
18+
},
19+
"postCreateCommand": ".devcontainer/postCreateCommand.sh",
20+
"remoteUser": "vscode",
21+
"containerUser": "vscode",
22+
"customizations": {
23+
"vscode": {
24+
"extensions": [
25+
"charliermarsh.ruff",
26+
"exiasr.hadolint",
27+
"foxundermoon.shell-format",
28+
"GitHub.copilot",
29+
"GitHub.vscode-github-actions",
30+
"Gruntfuggly.todo-tree",
31+
"ms-azuretools.vscode-docker",
32+
"ms-python.mypy-type-checker",
33+
"njpwerner.autodocstring",
34+
"oderwat.indent-rainbow",
35+
"tamasfe.even-better-toml",
36+
"tekumara.typos-vscode",
37+
"timonwong.shellcheck",
38+
"-ms-python.vscode-pylance"
39+
],
40+
"settings": {
41+
"terminal.integrated.defaultProfile.linux": "zsh",
42+
"python.defaultInterpreterPath": "./.venv/bin/python",
43+
"[python]": {
44+
"editor.formatOnSave": true,
45+
"editor.codeActionsOnSave": {
46+
"source.fixAll": "explicit",
47+
"source.organizeImports": "explicit"
48+
},
49+
"editor.defaultFormatter": "charliermarsh.ruff"
50+
}
51+
}
52+
}
53+
}
54+
}

.devcontainer/postCreateCommand.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euxo pipefail
4+
5+
uv sync --dev --all-extras
6+
uv run pre-commit install --allow-missing-config
7+
8+
cat<<'A'>> ~/.zshrc
9+
eval "$(uv generate-shell-completion zsh)"
10+
eval "$(uvx --generate-shell-completion zsh)"
11+
command -v deactivate &>/dev/null || . .venv/bin/activate
12+
A
13+
14+
sed -i ~/.zshrc -e 's/^ZSH_THEME=.*/ZSH_THEME="refined"/'
15+
16+
[[ -d .venv ]] || uv venv

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: uv
44
directory: /
55
schedule:
66
interval: monthly

.github/workflows/publish.yaml

+7-12
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,12 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- name: Install poetry
18-
run: pipx install poetry
19-
- uses: actions/setup-python@v5
17+
- uses: astral-sh/setup-uv@v5
2018
with:
21-
python-version: 3.x
22-
cache: poetry
23-
- name: Setup Poetry to publish
24-
run: |
25-
poetry install --no-interaction
26-
poetry config repositories.testpypi 'https://test.pypi.org/legacy/'
27-
poetry config pypi-token.testpypi '${{ secrets.TESTPYPI_API_TOKEN }}'
28-
poetry config pypi-token.pypi '${{ secrets.PYPI_API_TOKEN }}'
19+
enable-cache: true
20+
cache-dependency-glob: uv.lock
2921
- name: Publish package
30-
run: poetry run task publish
22+
run: uv run task publish
23+
env:
24+
TESTPYPI_API_TOKEN: ${{ secrets.TESTPYPI_API_TOKEN }}
25+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yaml

+10-7
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@ jobs:
2626
with:
2727
distribution: temurin
2828
java-version: '21'
29-
- name: Install poetry
30-
run: pipx install poetry
31-
- uses: actions/setup-python@v5
29+
- uses: astral-sh/setup-uv@v5
3230
with:
31+
enable-cache: true
32+
cache-dependency-glob: uv.lock
3333
python-version: ${{ matrix.python-version }}
34-
cache: poetry
3534
- name: Setup
3635
shell: bash
3736
run: |
38-
poetry install --no-interaction
3937
export DOWNLOAD_LATEST_ONLY=1
40-
poetry run task publish
38+
uv run task publish
4139
- name: Test
4240
run: |
43-
poetry run task test
41+
uv run task test:ci
42+
- name: Pytest coverage comment
43+
uses: MishaKav/[email protected]
44+
with:
45+
pytest-xml-coverage-path: ./coverage.xml
46+
junitxml-path: ./pytest.xml

.pre-commit-config.yaml

-8
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ repos:
2727
rev: v2.5.0
2828
hooks:
2929
- id: pyproject-fmt
30-
- repo: https://github.com/python-poetry/poetry
31-
rev: 2.0.0
32-
hooks:
33-
- id: poetry-check
34-
- repo: https://github.com/psf/black
35-
rev: 24.10.0
36-
hooks:
37-
- id: black
3830
- repo: https://github.com/astral-sh/ruff-pre-commit
3931
rev: v0.8.1
4032
hooks:

DEVELOPMENT.md

+7-17
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,34 @@
77

88
## Setup
99

10-
```bash
11-
pip install pipx
12-
pipx install poetry
13-
14-
poetry install
15-
poetry run pre-commit install
16-
```
17-
18-
## Activate virtual environment (venv) for development
19-
20-
```bash
21-
poetry shell
22-
```
10+
Open [Dev Container](https://code.visualstudio.com/docs/devcontainers/containers) in the cloned project.
2311

2412
## Lint
2513

2614
```bash
27-
# in venv:
2815
task lint
2916
```
3017

3118
## Fetch latest jar file
3219

3320
```bash
34-
# in venv:
3521
task download-latest-jar
3622
```
3723

3824
## Run tests for all unpublished versions without publishing
3925

4026
```bash
41-
# in venv:
4227
task test-unpublished-versions
4328
```
4429

30+
## Test
31+
32+
```bash
33+
task test
34+
```
35+
4536
## Publish all unpublished versions to PyPI (for CI)
4637

4738
```bash
48-
# in venv:
4939
task publish
5040
```

openapi_generator_cli/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def run(args: list[str] | None = None) -> subprocess.CompletedProcess[bytes]:
4545

4646
arguments.append("-jar")
4747

48-
jar_path = importlib.resources.files("openapi_generator_cli") / "openapi-generator.jar"
48+
jar_path = (
49+
importlib.resources.files("openapi_generator_cli") / "openapi-generator.jar"
50+
)
4951
arguments.append(str(jar_path))
5052

5153
if args and isinstance(args, list):

0 commit comments

Comments
 (0)