Skip to content

Commit

Permalink
chore(tool): switch from poetry to uv (#320)
Browse files Browse the repository at this point in the history
* chore(tool): switch from poetry to uv

* fix(ci): codecov upload token

---------

Co-authored-by: Matthew Anderson <matt@mandersience.com>
  • Loading branch information
maxb2 and Matthew Anderson authored Dec 17, 2024
1 parent 0e59831 commit 471e738
Show file tree
Hide file tree
Showing 14 changed files with 1,363 additions and 69 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.8

- name: Install Dependencies
run: poetry install -n --all-extras

- name: Linting and Type checking
run: |
make check
Expand All @@ -47,4 +40,6 @@ jobs:
make test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
- name: Install git-changelog
run: pip install git-cliff
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Prepare release notes
run: git-cliff -l -s all > release-notes.md
run: uvx git-cliff -l -s all > release-notes.md
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
Expand Down
24 changes: 13 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
PHONY=fmt-docs
fmt-docs:
find . -path './.venv' -prune -type f -o -name '*.md' -exec poetry run blacken-docs {} +
find . -path './.venv' -prune -type f -o -name '*.md' -exec uvx --from git+https://github.com/maxb2/blacken-docs@e82e9e9 blacken-docs {} +

PHONY=fmt
fmt:
poetry run isort --ca --profile=black .
poetry run black .
uvx isort --ca --profile=black .
uvx black .

PHONY=check-types
check-types:
poetry run mypy typer_config
uv run mypy src/typer_config

PHONY=ruff
ruff:
poetry run ruff check .
uvx ruff check .

PHONY=check
check: ruff check-types

PHONY=test
test:
poetry run pytest --cov=typer_config --cov-report=xml
uv run --all-extras pytest --cov=typer_config --cov-report=xml

PHONY=changelog
changelog:
poetry run git-cliff --output CHANGELOG.md
uvx git-cliff --output CHANGELOG.md

PHONY=release
release: changelog
NEXT_VERSION=$(shell poetry run git-cliff --bumped-version) && \
poetry version $$NEXT_VERSION && \
NEXT_VERSION=$(shell uvx git-cliff --bumped-version) && \
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $$NEXT_VERSION && \
git add pyproject.toml CHANGELOG.md && \
git commit -m "chore: Prepare release $$NEXT_VERSION" && \
poetry publish --build && \
mike deploy --push --update-aliases $$NEXT_VERSION latest && \
rm -rf ./dist && \
uv build && \
uv publish && \
uv run mike deploy --push --update-aliases $$NEXT_VERSION latest && \
git tag $$NEXT_VERSION && \
git push && \
git push --tags;
91 changes: 48 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
[tool.poetry]
[project]
name = "typer-config"
version = "1.4.2"
description = "Utilities for working with configuration files in typer CLIs. "
authors = ["Matt Anderson <matt@manderscience.com>"]
authors = [
{ name = "Matt Anderson", email = "matt@mandersience.com" }
]
readme = "README.md"
license = "MIT"
packages = [
{include = "typer_config"},
{include = "typer_config/py.typed"}
]
repository = "https://github.com/maxb2/typer-config"
documentation = "https://maxb2.github.io/typer-config/"
homepage = "https://maxb2.github.io/typer-config/"
Expand Down Expand Up @@ -43,42 +41,53 @@ classifiers = [
"License :: OSI Approved :: MIT License"
]

[tool.poetry.dependencies]
python = "^3.9"
typer = "^0"
toml = {version = "^0.10.2", optional = true}
pyyaml = {version = "^6.0", optional = true}
python-dotenv = {version = "*", optional = true}
requires-python = ">=3.9"
dependencies = [
"typer==0.*",
]

[project.optional-dependencies]
all = [
"python-dotenv>=0",
"toml>=0.10.2,<1",
"pyyaml==6.*",
]
python-dotenv = [
"python-dotenv>=0",
]
toml = [
"toml>=0.10.2,<1",
]
yaml = [
"pyyaml==6.*",
]

[tool.poetry.extras]
python-dotenv = ["python-dotenv"]
toml = ["toml"]
yaml = ["pyyaml"]
all = ["toml", "pyyaml", "python-dotenv"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.0.263,<0.8.3"
black = ">=23.3,<25.0"
isort = "^5.12.0"
pytest = ">=7.3.1,<9.0.0"
mypy = "^1.2.0"
types-toml = "^0.10.8.6"
types-pyyaml = "^6.0.12.9"
pytest-cov = ">=4,<7"
griffe = ">=0.32.2,<1.6.0"
git-cliff = "^2.6.1"
[tool.hatch.build.targets.sdist]
include = [
"src/typer_config/*.py",
"src/typer_config/py.typed",
]

[tool.poetry.group.docs.dependencies]
mkdocs-material = "^9.1.9"
mkdocstrings = {extras = ["python"], version = ">=0.21.2,<0.28.0"}
mike = ">=1.1.2,<3.0.0"
mkdocs-gen-files = "^0.5.0"
pydantic = ">=1.10.7,<3.0.0"
blacken-docs = { git = "https://github.com/maxb2/blacken-docs.git", rev = "e82e9e9e1eeee37fd89b9c2d6e3c99cf0aa2d399" }
schema = "^0.7.5"
[tool.hatch.build.targets.wheel]
sources = ["src"]

[tool.isort]
profile = "black"
[dependency-groups]
dev = [
"black>=24.10.0",
"mike>=2.1.3",
"mkdocs-gen-files>=0.5.0",
"mkdocs-material>=9.5.49",
"mkdocstrings[python]>=0.27.0",
"mypy>=1.13.0",
"pydantic>=2.10.3",
"pytest>=8.3.4",
"pytest-cov>=6.0.0",
"schema>=0.7.7",
]

[tool.ruff.lint]
extend-select = [ # https://beta.ruff.rs/docs/rules/
Expand Down Expand Up @@ -127,9 +136,5 @@ extend-ignore = ["D202", "D205", "D107"]
[tool.ruff.lint.pydocstyle]
convention = "google" # Accepts: "google", "numpy", or "pep257".

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
addopts = "-p no:warnings"
addopts = "-p no:warnings"
4 changes: 4 additions & 0 deletions typer_config/__init__.py → src/typer_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Typer Configuration Utilities."""

import importlib.metadata

from .callbacks import (
conf_callback_factory,
dotenv_conf_callback,
Expand All @@ -16,6 +18,8 @@
)
from .loaders import dotenv_loader, ini_loader, json_loader, toml_loader, yaml_loader

__version__ = importlib.metadata.version("typer_config")

__all__ = [
"conf_callback_factory",
"dotenv_conf_callback",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 471e738

Please sign in to comment.