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

Switch poetry to uv #98

Merged
merged 3 commits into from
Jan 31, 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
18 changes: 7 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.11'
PRECOMMIT_VERSION: '3.7.1'

jobs:
pre-commit:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Configure Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true

- name: Install pre-commit
run: pip install pre-commit==${{ env.PRECOMMIT_VERSION }}
- name: Install dependencies
run: uv sync --no-install-project --group lint

- name: Cache pre-commit
uses: actions/cache@v4
Expand All @@ -31,4 +27,4 @@ jobs:
key: precommit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: pre-commit run --all-files
run: make fmt
32 changes: 5 additions & 27 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,19 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
PYTHON_VERSION: '3.11'
POETRY_VERSION: '1.8.3'

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Configure Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-v1-${{ hashFiles('**/poetry.lock') }}
enable-cache: true

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-root --only main,test

- name: Install library
run: poetry install --only main,test
run: uv sync --group test

- name: Run tests and generate coverage report
run: make coverage
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ target/
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.6
rev: v0.9.4
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: pretty-format-json
args: [--autofix, --no-sort-keys]

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.13.0
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix, --no-sort, --trailing-commas]
exclude: poetry.lock
exclude: uv.lock
- id: pretty-format-yaml
args: [--autofix, --offset=2, --preserve-quotes]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.22
hooks:
- id: mdformat

- repo: https://github.com/crate-ci/typos
rev: v1.21.0
rev: v1.29.5
hooks:
- id: typos
args: [--force-exclude]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.14.1
hooks:
- id: mypy
args: []
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ SHELL=bash

.PHONY: fmt
fmt: ## Run autoformatting and linting
@poetry run pre-commit run --all-files
@uv run pre-commit run --all-files

.PHONY: test
test: ## Run tests
@poetry run pytest
@uv run pytest

.PHONY: coverage
coverage: ## Run tests and report coverage
@poetry run coverage run -m pytest
@poetry run coverage report
@uv run coverage run -m pytest
@uv run coverage report

.PHONY: clean
clean: ## Clean up caches and build artifacts
Expand Down
483 changes: 0 additions & 483 deletions poetry.lock

This file was deleted.

51 changes: 29 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
[project]
name = "mypackage"
version = "0.1.0"
description = ""
authors = ["Stijn de Gooijer <stijn@degooijer.io>"]
repository = "https://github.com/stinodego/python-cookiecutter"
description = "Example package"
authors = [
{name = "Stijn de Gooijer", email = "stijndegooijer@gmail.com"},
]
repository = "https://github.com/stinodego/python-ci"
readme = "README.md"
packages = [{include = "mypackage", from = "src"}]
requires-python = ">=3.11"
dependencies = [
"polars>=1.21.0",
]

[tool.poetry.scripts]
mycli = 'mypackage.main:main'
[project.scripts]
mycli = 'mypackage.__main__:main'

[tool.poetry.dependencies]
python = ">=3.11"
polars = "^0.20.30"
[dependency-groups]
test = [
"coverage>=7.6.10",
"pytest>=8.3.4",
"pytest-mock>=3.14.0",
]
lint = [
"mypy>=1.14.1",
"pre-commit>=4.1.0",
"ruff>=0.9.4",
]

[tool.poetry.group.test.dependencies]
pytest = "^8.2.1"
pytest-mock = "^3.14.0"
coverage = "^7.5.3"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry.group.lint.dependencies]
pre-commit = "^3.7.1"
ruff = "^0.4.6"
mypy = "^1.10.0"
[tool.uv]
required-version = "0.5.26"
default-groups = ["test", "lint"]

[tool.ruff]
src = ["src"]
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/unit/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mypackage.main import main
from mypackage.__main__ import main


def test_main():
Expand Down
Loading