Skip to content

Commit 5d5c168

Browse files
committed
feat: support for python 3.14
1 parent b443790 commit 5d5c168

File tree

13 files changed

+2061
-2191
lines changed

13 files changed

+2061
-2191
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
if: github.event.workflow_run.conclusion == 'success'
1313
steps:
1414
- uses: actions/checkout@main
15-
- name: Install poetry
16-
run: pipx install poetry
17-
- name: Setup poetry
18-
run: poetry config pypi-token.pypi ${{ secrets.pypy }}
19-
- name: Build and publish
20-
run: poetry publish --build
15+
- uses: astral-sh/setup-uv@v7
16+
with:
17+
enable-cache: true
18+
19+
- name: Build Package
20+
run: |
21+
uv build
22+
uv publish --token ${{ secrets.pypy }}

.github/workflows/tests.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,23 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.10", "3.11", "3.12", "3.13"]
18+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
1919

2020
steps:
2121
- uses: actions/checkout@main
22-
- name: install poetry
23-
run: pip install poetry
24-
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@main
22+
- uses: astral-sh/setup-uv@v7
2723
with:
28-
cache: poetry
24+
enable-cache: true
2925
python-version: ${{ matrix.python-version }}
3026

31-
- name: Setup requirements
32-
run: poetry install --with dev
27+
- name: Setup dependencies
28+
run: uv sync --locked --all-extras --dev
3329

3430
- name: Check code
35-
run: poetry run ruff check muffin
31+
run: uv run ruff check muffin
3632

3733
- name: Check typing
38-
run: poetry run mypy
34+
run: uv run mypy
3935

4036
- name: Test with pytest
41-
run: poetry run pytest tests
37+
run: uv run pytest tests

.pre-commit-config.yaml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
stages: ["commit-msg"]
1414

1515
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v5.0.0
16+
rev: v6.0.0
1717
hooks:
1818
- id: check-case-conflict
1919
stages: ["pre-commit"]
@@ -39,42 +39,39 @@ repos:
3939
stages: ["pre-commit"]
4040

4141
- repo: https://github.com/psf/black
42-
rev: 25.1.0
42+
rev: 25.9.0
4343
hooks:
4444
- id: black
4545
stages: ["pre-commit"]
4646

47-
- repo: https://github.com/python-poetry/poetry
48-
rev: "2.1.3"
47+
- repo: https://github.com/astral-sh/uv-pre-commit
48+
rev: 0.9.7
4949
hooks:
50-
- id: poetry-check
51-
files: ^(.*/)?pyproject\.toml$
52-
stages: ["pre-commit"]
53-
- id: poetry-lock
54-
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
50+
- id: uv-lock
51+
args: ["--check"]
5552
stages: ["pre-commit"]
5653

5754
- repo: local
5855
hooks:
5956
- id: ruff
6057
name: ruff
61-
entry: poetry run ruff check muffin
58+
entry: uv run ruff check muffin
6259
language: system
6360
pass_filenames: false
6461
files: \.py$
6562
stages: ["pre-commit"]
6663

6764
- id: mypy
6865
name: mypy
69-
entry: poetry run mypy
66+
entry: uv run mypy
7067
language: system
7168
pass_filenames: false
7269
files: \.py$
7370
stages: ["pre-push"]
7471

7572
- id: pytest
7673
name: pytest
77-
entry: poetry run pytest tests
74+
entry: uv run pytest tests
7875
language: system
7976
pass_filenames: false
8077
files: \.py$

Makefile

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,31 @@ all: $(VIRTUAL_ENV)
77
# Development
88
# =============
99

10-
$(VIRTUAL_ENV): pyproject.toml .pre-commit-config.yaml .git-commits.yaml
11-
@poetry install --with dev -E standard
12-
@poetry run pre-commit install
13-
@touch $(VIRTUAL_ENV)
10+
$(VIRTUAL_ENV): uv.lock .pre-commit-config.yaml
11+
@echo "Setting up virtual environment and installing dependencies..."
12+
@uv sync --all-groups
13+
@GIT_CONFIG=/dev/null && uv run pre-commit install
14+
@touch $(VIRTUAL_ENV) # Create a marker file
1415

1516
.PHONY: t test
1617
# target: test - Run tests
1718
t test: $(VIRTUAL_ENV)
18-
@poetry run pytest -xsvl --mypy tests
19+
@uv run pytest -xsvl --mypy tests
1920

2021
.PHONY: lint
2122
# target: mypy - Run typechecking
2223
lint: $(VIRTUAL_ENV)
23-
@poetry run ruff muffin
24-
@poetry run mypy
24+
@uv run ruff muffin
25+
@uv run mypy
2526

2627
.PHONY: mypy
2728
# target: mypy - Run typechecking
2829
mypy: $(VIRTUAL_ENV)
29-
@poetry run mypy
30+
@uv run mypy
3031

3132
.PHONY: docs
3233
docs: $(VIRTUAL_ENV)
33-
@poetry run sphinx-build docs/ docs/_build -b html
34+
@uv run sphinx-build docs/ docs/_build -b html
3435
# @$(VIRTUAL_ENV)/bin/python setup.py upload_sphinx --upload-dir=docs/_build/html
3536

3637

@@ -55,12 +56,14 @@ release: $(VIRTUAL_ENV)
5556
@git checkout master
5657
@git pull
5758
@git merge develop
58-
@poetry version $(VERSION)
59-
@git commit -am "build(release): `poetry version -s`"
60-
@git tag `poetry version -s`
59+
@uvx bump-my-version bump $(VERSION)
60+
@uv lock
61+
@git commit -am "build(release): `uv version --short`"
62+
@git tag `uv version --short`
6163
@git checkout develop
6264
@git merge master
6365
@git push --tags origin develop master
66+
@echo "Release process complete for `uv version --short`."
6467

6568
.PHONY: minor
6669
minor: release
@@ -75,4 +78,4 @@ major:
7578

7679
.PHONY: version v
7780
version v:
78-
@poetry version -s
81+
@uv version --short

muffin/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from modconfig import Config
1414

1515
from muffin.constants import CONFIG_ENV_VARIABLE
16+
from muffin.manage import Manager
1617
from muffin.utils import import_submodules, logger
1718

1819
if TYPE_CHECKING:
@@ -70,7 +71,6 @@ def __init__(self, *cfg_mods: str | ModuleType, **options):
7071
self.cfg.update_from_env(prefix=f"{ self.cfg.name }_")
7172

7273
# Setup CLI
73-
from muffin.manage import Manager
7474

7575
self.manage = Manager(self)
7676

muffin/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HandlerMeta(type):
2121

2222
def __new__(mcs: type[HandlerMeta], name: str, bases: tuple[type], params: dict[str, Any]):
2323
"""Prepare a Handler Class."""
24-
cls = cast(type["Handler"], super().__new__(mcs, name, bases, params))
24+
cls = cast("type[Handler]", super().__new__(mcs, name, bases, params))
2525

2626
# Ensure that the class methods are exist and iterable
2727
if not cls.methods:

muffin/manage.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def shell(*, ipython: bool = True):
9898
banner += f"Loaded globals: {list(ctx.keys())}\n"
9999
if ipython:
100100
with suppress(ImportError):
101-
from IPython.terminal.embed import InteractiveShellEmbed
101+
from IPython.terminal.embed import InteractiveShellEmbed # noqa: PLC0415
102102

103103
sh = InteractiveShellEmbed.instance(banner1=banner, user_ns=ctx)
104104
return sh()
@@ -109,15 +109,10 @@ def shell(*, ipython: bool = True):
109109

110110
def run(host: str = "localhost", port: int = 5000):
111111
"""Run the application with the given host and port."""
112-
from uvicorn.main import run as urun
112+
from uvicorn.main import run as urun # noqa: PLC0415
113113

114114
cfg = self.app.cfg
115-
return urun(
116-
self.app,
117-
host=host,
118-
port=port,
119-
log_config=cfg.LOG_CONFIG,
120-
)
115+
return urun(self.app, host=host, port=port, log_config=cfg.LOG_CONFIG)
121116

122117
self(run)
123118

muffin/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from abc import ABC
6-
from asyncio import iscoroutinefunction
6+
from inspect import iscoroutinefunction
77
from typing import TYPE_CHECKING, Any, Awaitable, Callable, ClassVar, Mapping
88

99
from modconfig import Config

muffin/pytest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import pytest
1111
from asgi_tools.tests import ASGITestClient, manage_lifespan
1212

13+
from muffin.constants import CONFIG_ENV_VARIABLE
14+
from muffin.utils import import_app
15+
1316
if TYPE_CHECKING:
1417
from muffin.app import Application
1518

@@ -33,7 +36,6 @@ def pytest_addoption(parser):
3336

3437
def pytest_load_initial_conftests(early_config, parser, args):
3538
"""Prepare to loading Muffin application."""
36-
from muffin.constants import CONFIG_ENV_VARIABLE
3739

3840
options = parser.parse_known_args(args)
3941

@@ -51,14 +53,12 @@ def pytest_load_initial_conftests(early_config, parser, args):
5153
async def app(pytestconfig, request, aiolib): # noqa: ARG001
5254
"""Load an application, run lifespan events, prepare plugins."""
5355
if not pytestconfig.app:
54-
logging.warning(
56+
logging.warning( # noqa: LOG015
5557
"Improperly configured. Please set ``muffin_app`` in your pytest config. "
5658
"Or use ``--muffin-app`` command option.",
5759
)
5860
return
5961

60-
from muffin.utils import import_app
61-
6262
muffin_app = import_app(pytestconfig.app)
6363
msg = f"Setup application '{muffin_app.cfg.name}'"
6464
if muffin_app.cfg.config:
@@ -89,7 +89,7 @@ async def lifecycle(app: Application):
8989
yield app
9090

9191

92-
@pytest.fixture()
92+
@pytest.fixture
9393
def client(app):
9494
"""Generate a test client for the app."""
9595
return ASGITestClient(app)

0 commit comments

Comments
 (0)