Skip to content

Commit 4b856ed

Browse files
authored
Merge pull request #30 from dbast/poetry-update
Modernize packaging and CI for Poetry 2 and Python 3.10+
2 parents e473985 + 503416a commit 4b856ed

7 files changed

Lines changed: 102 additions & 44 deletions

File tree

.circleci/config.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
tox:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
# testing upper and lower bounds of non EOL Python versions
21+
# according to https://devguide.python.org/versions/
22+
- python-version: "3.10"
23+
toxenv: py310
24+
- python-version: "3.14"
25+
toxenv: py314
26+
name: ${{ matrix.python-version }}
27+
steps:
28+
- name: Check out code
29+
uses: actions/checkout@v6
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install tox
37+
run: python -m pip install --upgrade pip "tox>=4"
38+
39+
- name: Run tox env
40+
run: tox -e ${{ matrix.toxenv }}
41+
42+
package:
43+
runs-on: ubuntu-latest
44+
name: Build sdist
45+
steps:
46+
- name: Check out code
47+
uses: actions/checkout@v6
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v6
51+
with:
52+
python-version: "3.12"
53+
54+
- name: Install Poetry
55+
run: python -m pip install --upgrade pip "poetry>=2,<3"
56+
57+
- name: Build sdist
58+
run: poetry build -f sdist
59+
60+
- name: Upload sdist artifact
61+
uses: actions/upload-artifact@v6
62+
with:
63+
name: timing-asgi-sdist
64+
path: dist/*.tar.gz

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# timing-asgi
2-
[![CircleCI](https://circleci.com/gh/steinnes/timing-asgi.svg?style=svg&circle-token=4e141ed4d7231ab6d00dc7b14624d759cf16e1d2)](https://circleci.com/gh/steinnes/timing-asgi)
2+
[![CI](https://github.com/steinnes/timing-asgi/actions/workflows/ci.yml/badge.svg)](https://github.com/steinnes/timing-asgi/actions/workflows/ci.yml)
33
[![PyPI Downloads](https://img.shields.io/pypi/dm/timing-asgi.svg)](https://pypi.org/project/timing-asgi/)
44
[![PyPI Version](https://img.shields.io/pypi/v/timing-asgi.svg)](https://pypi.org/project/timing-asgi/)
55
[![License](https://img.shields.io/badge/license-mit-blue.svg)](https://pypi.org/project/timing-asgi/)

pyproject.toml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
[tool.poetry]
1+
[project]
22
name = "timing-asgi"
33
version = "0.3.1"
44
description = "ASGI middleware to emit timing metrics with something like statsd"
5-
authors = ["Steinn Eldjárn Sigurðarson <steinnes@gmail.com>"]
5+
authors = [
6+
{ name = "Steinn Eldjárn Sigurðarson", email = "steinnes@gmail.com" },
7+
]
68
readme = "README.md"
79
license = "MIT"
8-
include = ["LICENSE"]
10+
requires-python = ">=3.10"
911

1012
[project.urls]
1113
"Source" = "https://github.com/steinnes/timing-asgi"
1214

13-
[tool.poetry.dependencies]
14-
python = "^3.6"
15+
[tool.poetry]
16+
include = ["LICENSE"]
1517

16-
[tool.poetry.dev-dependencies]
17-
starlette = "^0.12.0"
18-
pytest = "^4.3"
19-
pytest-cov = "^2.6"
20-
requests = "^2.21"
21-
pytest-asyncio = "^0.10.0"
22-
asynctest = "^0.12.2"
23-
flake8 = "^3.7"
24-
black = {version = "^20.8b1", allow-prereleases = true}
18+
[tool.poetry.group.dev.dependencies]
19+
starlette = "^0.52.0"
20+
pytest = "^9"
21+
pytest-cov = "^7.0.0"
22+
requests = "^2.32.2"
23+
pytest-asyncio = "^1.3.0"
24+
flake8 = "^7.3"
25+
black = "^26.1.0"
2526

2627
[build-system]
27-
requires = ["poetry>=0.12"]
28-
build-backend = "poetry.masonry.api"
28+
requires = ["poetry-core>=2.0.0,<3.0.0"]
29+
build-backend = "poetry.core.masonry.api"

tests/conftest.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asynctest
21
import pytest
32

43
from unittest import mock
@@ -8,29 +7,29 @@
87
from timing_asgi import TimingMiddleware
98

109

11-
@pytest.yield_fixture(scope="function")
10+
@pytest.fixture(scope="function")
1211
def starlette_app():
1312
yield Starlette()
1413

1514

16-
@pytest.yield_fixture(scope="function")
15+
@pytest.fixture(scope="function")
1716
def timing_client(starlette_app):
1817
yield mock.MagicMock()
1918

2019

21-
@pytest.yield_fixture(scope="function")
20+
@pytest.fixture(scope="function")
2221
def mw(starlette_app, timing_client):
2322
yield TimingMiddleware(starlette_app, client=timing_client)
2423

2524

26-
@pytest.yield_fixture(scope="function")
25+
@pytest.fixture(scope="function")
2726
def send():
28-
yield asynctest.CoroutineMock()
27+
yield mock.AsyncMock()
2928

3029

31-
@pytest.yield_fixture(scope="function")
30+
@pytest.fixture(scope="function")
3231
def receive():
33-
yield asynctest.CoroutineMock()
32+
yield mock.AsyncMock()
3433

3534

3635
@pytest.fixture

tests/test_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_timing_middleware_init_calls_ensure_compliance(starlette_app):
5050
"timing_asgi.TimingMiddleware.ensure_compliance"
5151
) as mock_ensure_compliance:
5252
TimingMiddleware(starlette_app, client="foo")
53-
assert mock_ensure_compliance.called_with("foo")
53+
mock_ensure_compliance.assert_called_with("foo")
5454

5555

5656
@pytest.mark.asyncio

tox.ini

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
[tox]
2-
skipsdist=True
3-
isolated_build = true
4-
envlist =
5-
py36,
6-
py37,
7-
py38
2+
min_version = 4.0
3+
requires =
4+
tox>=4
5+
env_list =
6+
py310,
7+
py311,
8+
py312,
9+
py313,
10+
py314
11+
package = skip
812

913
[testenv]
10-
whitelist_externals = /usr/bin/make
14+
allowlist_externals = make
1115
commands =
12-
pip install poetry
16+
pip install "poetry>=2,<3"
1317
poetry install -v
1418
make lint
1519
make test

0 commit comments

Comments
 (0)