Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Poetry to uv #60

Merged
merged 11 commits into from
Nov 4, 2024
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
16 changes: 8 additions & 8 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "1.6.1"
virtualenvs-in-project: true
- name: Install dynamic versioning plugin for Poetry
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Build and publish to PyPI
run: poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
version: "0.4.29"
enable-cache: true
- name: Build package
run: uv build
- name: Publish package to PyPI
run: uv publish
2 changes: 1 addition & 1 deletion .github/workflows/summary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
checks: read
steps:
- name: Wait for all triggered status checks
uses: poseidon/wait-for-status-checks@v0.5.0
uses: poseidon/wait-for-status-checks@v0.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
ignore_pattern: ^codecov/.+
72 changes: 33 additions & 39 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.local
key: poetry-0 # increment to reset cache
- name: Install and configure Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: "1.8.3"
virtualenvs-in-project: true
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
- name: Run Poetry check
run: poetry check
version: "0.4.29"
enable-cache: true
- name: Install Python
run: uv python install 3.12
- name: Install dependencies
run: poetry install --no-interaction --all-extras
run: uv sync --all-extras --frozen
- name: Run checks
run: poetry run make check
run: uv run make check
- name: Run tests and create coverage report
run: poetry run make test-coverage
run: uv run make test-coverage
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
with:
Expand All @@ -61,8 +50,9 @@ jobs:
deps:
- starlette
- fastapi starlette
- fastapi==0.109.0 starlette
- fastapi==0.100.1 starlette
- fastapi==0.87.0 starlette anyio==3.*
- fastapi==0.88.0 starlette
- flask
- flask==2.3.*
- flask==2.0.3 Werkzeug==2.*
Expand All @@ -75,29 +65,33 @@ jobs:
- django-ninja==0.18.0 django
- litestar
- litestar==2.6.1
- litestar==2.3.0
- litestar==2.0.1
exclude:
- python: "3.12"
deps: fastapi==0.100.1 starlette
- python: "3.12"
deps: fastapi==0.87.0 starlette
- python: "3.12"
deps: djangorestframework==3.12.* django==3.2.* uritemplate
- python: "3.12"
deps: djangorestframework==3.10.* django==2.2.* uritemplate
- python: "3.12"
deps: litestar==2.0.1
steps:
- uses: actions/checkout@v4
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- name: Install and configure Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: "1.8.3"
virtualenvs-in-project: true
version: "0.4.29"
enable-cache: true
- name: Install Python
run: uv python install ${{ matrix.python }}
- name: Build Python package wheel
run: poetry build -f wheel
- uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python }}"
run: uv build --wheel
- name: Install test dependencies
run: poetry install --no-interaction --no-root --only test
run: uv sync --no-install-project --only-group test --frozen
- name: Install app dependencies
run: poetry run pip install ${{ matrix.deps }} ./dist/apitally-*.whl
run: uv pip install ${{ matrix.deps }} ./dist/apitally-*.whl
- name: Run tests
run: poetry run make test
run: uv run make test
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ coverage.xml
.dmypy.json
dmypy.json

# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

Expand Down
8 changes: 3 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ repos:
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
- id: ruff-format
- repo: https://github.com/python-poetry/poetry
rev: "1.8.4"
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.29
hooks:
- id: poetry-check
- id: poetry-lock
args: ["--check", "--no-update"]
- id: uv-lock
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ format:
ruff format apitally tests

check:
uv lock --locked
ruff check apitally tests
ruff format --diff apitally tests
mypy --install-types --non-interactive apitally tests
poetry check

test:
pytest -v --tb=short
Expand Down
7 changes: 6 additions & 1 deletion apitally/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import contextlib
import os
import re
import sys
import threading
import time
import traceback
Expand Down Expand Up @@ -328,7 +329,11 @@
cutoff = MAX_EXCEPTION_TRACEBACK_LENGTH - len(prefix)
lines = []
length = 0
for line in traceback.format_exception(exception)[::-1]:
if sys.version_info >= (3, 10):
traceback_lines = traceback.format_exception(exception)
else:
traceback_lines = traceback.format_exception(type(exception), exception, exception.__traceback__)

Check warning on line 335 in apitally/client/base.py

View check run for this annotation

Codecov / codecov/patch

apitally/client/base.py#L335

Added line #L335 was not covered by tests
for line in traceback_lines[::-1]:
if length + len(line) > cutoff:
lines.append(prefix)
break
Expand Down
Loading