Skip to content

migrate to uv + ruff #30

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

Merged
merged 7 commits into from
Feb 10, 2025
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
26 changes: 8 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,18 @@ jobs:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Checks
run: |
poetry --version
poetry check --no-interaction
- name: Install deps
run: poetry install --no-interaction
run: uv sync --frozen
- name: Run tests
run: poetry run pytest -v
run: uv run --no-sync pytest -v
- name: Build
run: uv build
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: uv publish
29 changes: 9 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,18 @@ jobs:
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
- uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Checks
run: |
poetry --version
poetry check --no-interaction
enable-cache: true
- name: Add version to environment vars
run: |
PROJECT_VERSION=$(poetry version --short)
PROJECT_VERSION=$(uvx dunamai from any --format "{base}")
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
Expand All @@ -51,18 +44,14 @@ jobs:
echo $PROJECT_VERSION
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi

- name: Checks
run: |
poetry --version
poetry check --no-interaction
- name: Install deps
run: poetry install --no-interaction
run: uv sync --frozen
- name: Run tests
run: poetry run pytest -v
run: uv run --no-sync pytest -v
- name: Build
run: poetry build
run: uv build
- name: Create Release Draft
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
21 changes: 7 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,17 @@ jobs:
- celery-version: ">=5.3,<5.4"
python-version: "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
- uses: actions/cache@v3
- uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Checks
run: |
poetry --version
poetry check --no-interaction
enable-cache: true
- name: Install project
run: |
poetry install --no-interaction
pip install celery"${{ matrix.celery-version }}"
uv sync --frozen
uv pip install celery"${{ matrix.celery-version }}"
- name: Run tests
run: poetry run pytest -v
run: uv run --no-sync pytest -v
37 changes: 14 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
exclude: ^static/.*|assets/.*|/migrations/.*|\.min\.js$|\.min\.css$|\.css\.map$|\.min\.js$|\.js\.map$|\.svg$
default_language_version:
python: python3.11
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: isort
name: isort (python)
args: ["--filter-files", "--profile", "black", "--line-length=120"]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: ["--line-length=120"]
language_version: python3.10
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: [--maxkb=2048]
args: [ --maxkb=2048 ]
- id: check-toml
types: [toml]
types: [ toml ]
- id: check-yaml
types: [yaml]
types: [ yaml ]
- id: end-of-file-fixer
types: [text]
stages: [commit, push, manual]
types: [ text ]
stages: [ pre-commit, pre-push, manual ]
- id: trailing-whitespace
types: [text]
stages: [commit, push, manual]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
exclude: taskbadger.yaml
types: [ text ]
stages: [ pre-commit, pre-push, manual ]
7 changes: 6 additions & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import os

import taskbadger as tb
from examples.migration_utils import get_data_chunks, get_total, prepare_migration, process_chunk
from examples.migration_utils import (
get_data_chunks,
get_total,
prepare_migration,
process_chunk,
)
from taskbadger import EmailIntegration


Expand Down
2 changes: 1 addition & 1 deletion integration_tests/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@pytest.fixture(autouse=True)
def check_log_errors(caplog):
def _check_log_errors(caplog):
yield
for when in ("call", "setup", "teardown"):
errors = [r.getMessage() for r in caplog.get_records(when) if r.levelno == logging.ERROR]
Expand Down
Loading