Skip to content

Commit f99f03e

Browse files
Sync from aiohttp (#69)
1 parent 4d26496 commit f99f03e

File tree

7 files changed

+98
-26
lines changed

7 files changed

+98
-26
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: pip
5+
directory: /
6+
schedule:
7+
interval: daily
8+
9+
- package-ecosystem: github-actions
10+
directory: /
11+
schedule:
12+
interval: monthly

.github/workflows/auto-merge.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Dependabot auto-merge
3+
on: pull_request_target
4+
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.actor == 'dependabot[bot]' }}
13+
steps:
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v2
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Enable auto-merge for Dependabot PRs
20+
run: gh pr merge --auto --squash "$PR_URL"
21+
env:
22+
PR_URL: ${{github.event.pull_request.html_url}}
23+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/ci.yaml

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@
22
name: CI
33

44
on:
5+
merge_group:
56
push:
67
branches: [master]
78
tags: [v*]
89
pull_request:
9-
branches: [master]
10-
workflow_dispatch:
1110

1211
jobs:
1312
lint:
1413
name: Run linters
1514
runs-on: ubuntu-latest
1615
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-python@v2
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.11
20+
cache: pip
21+
cache-dependency-path: '**/requirements*.txt'
22+
- name: Install dependencies
23+
uses: py-actions/py-dependency-install@v4
24+
with:
25+
path: requirements-dev.txt
26+
- name: Run mypy
27+
run: mypy
1928
- name: Install check-wheel-content, pre-commit, and twine
2029
run: python -m pip install build pre-commit check-wheel-contents twine
2130
- name: Build package
@@ -30,23 +39,42 @@ jobs:
3039
test:
3140
strategy:
3241
matrix:
33-
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
42+
pyver: ['3.9', '3.10', '3.11', '3.12', '3.13']
3443
runs-on: ubuntu-latest
3544

3645
steps:
37-
- uses: actions/checkout@v2
38-
- name: Set up Python ${{ matrix.python-version }}
39-
uses: actions/setup-python@v2
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
- name: Setup Python ${{ matrix.pyver }}
49+
uses: actions/setup-python@v5
4050
with:
41-
python-version: ${{ matrix.python-version }}
42-
- name: Install Python ${{ matrix.python-version }} dependencies
43-
run: |
44-
python -m pip install --upgrade pip
45-
pip install .
51+
python-version: ${{ matrix.pyver }}
52+
cache: pip
53+
cache-dependency-path: '**/requirements*.txt'
54+
- name: Install dependencies
55+
uses: py-actions/py-dependency-install@v4
56+
with:
57+
path: requirements.txt
4658
- name: Run pytest
4759
run: pytest
4860

4961

62+
check: # This job does nothing and is only used for the branch protection
63+
if: always()
64+
65+
needs:
66+
- lint
67+
- test
68+
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- name: Decide whether the needed jobs succeeded or failed
73+
uses: re-actors/alls-green@release/v1
74+
with:
75+
jobs: ${{ toJSON(needs) }}
76+
77+
5078
deploy:
5179
name: Deploy
5280
environment: release

pytest_aiohttp/plugin.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Awaitable, Iterator
1+
from collections.abc import AsyncIterator, Awaitable
22
from typing import (
33
Any,
44
Dict,
@@ -20,8 +20,9 @@
2020

2121

2222
class AiohttpClient(Protocol):
23+
# TODO(PY311): Use Unpack to specify ClientSession kwargs.
2324
@overload
24-
async def __call__(
25+
async def __call__( # type: ignore[misc]
2526
self,
2627
__param: Application,
2728
*,
@@ -30,7 +31,7 @@ async def __call__(
3031
) -> TestClient[Request, Application]: ...
3132

3233
@overload
33-
async def __call__(
34+
async def __call__( # type: ignore[misc]
3435
self,
3536
__param: BaseTestServer, # TODO(aiohttp4): BaseTestServer[_Request]
3637
*,
@@ -64,7 +65,7 @@ def __call__(
6465

6566

6667
@pytest.hookimpl(tryfirst=True)
67-
def pytest_configure(config) -> None:
68+
def pytest_configure(config: pytest.Config) -> None:
6869
val = config.getoption("asyncio_mode")
6970
if val is None:
7071
val = config.getini("asyncio_mode")
@@ -74,7 +75,7 @@ def pytest_configure(config) -> None:
7475

7576

7677
@pytest_asyncio.fixture
77-
async def aiohttp_server() -> Iterator[AiohttpServer]:
78+
async def aiohttp_server() -> AsyncIterator[AiohttpServer]:
7879
"""Factory to create a TestServer instance, given an app.
7980
8081
aiohttp_server(app, **kwargs)
@@ -100,7 +101,7 @@ async def go(
100101

101102

102103
@pytest_asyncio.fixture
103-
async def aiohttp_raw_server() -> Iterator[AiohttpRawServer]:
104+
async def aiohttp_raw_server() -> AsyncIterator[AiohttpRawServer]:
104105
"""Factory to create a RawTestServer instance, given a web handler.
105106
106107
aiohttp_raw_server(handler, **kwargs)
@@ -124,8 +125,8 @@ async def go(
124125
await servers.pop().close()
125126

126127

127-
@pytest_asyncio.fixture
128-
def aiohttp_client_cls() -> Type[TestClient[Any, Any]]:
128+
@pytest.fixture
129+
def aiohttp_client_cls() -> Type[TestClient[Any, Any]]: # type: ignore[misc]
129130
"""
130131
Client class to use in ``aiohttp_client`` factory.
131132
@@ -152,9 +153,9 @@ def test_login(aiohttp_client):
152153

153154

154155
@pytest_asyncio.fixture
155-
async def aiohttp_client(
156+
async def aiohttp_client( # type: ignore[misc]
156157
aiohttp_client_cls: Type[TestClient[Any, Any]],
157-
) -> Iterator[AiohttpClient]:
158+
) -> AsyncIterator[AiohttpClient]:
158159
"""Factory to create a TestClient instance.
159160
160161
aiohttp_client(app, **kwargs)
@@ -164,15 +165,15 @@ async def aiohttp_client(
164165
clients = []
165166

166167
@overload
167-
async def go(
168+
async def go( # type: ignore[misc]
168169
__param: Application,
169170
*,
170171
server_kwargs: Optional[Dict[str, Any]] = None,
171172
**kwargs: Any,
172173
) -> TestClient[Request, Application]: ...
173174

174175
@overload
175-
async def go(
176+
async def go( # type: ignore[misc]
176177
__param: BaseTestServer, # TODO(aiohttp4): BaseTestServer[_Request]
177178
*,
178179
server_kwargs: Optional[Dict[str, Any]] = None,
@@ -187,6 +188,7 @@ async def go(
187188
server_kwargs: Optional[Dict[str, Any]] = None,
188189
**kwargs: Any,
189190
) -> TestClient[Any, Any]:
191+
# TODO(PY311): Use Unpack to specify ClientSession kwargs and server_kwargs.
190192
if isinstance(__param, Application):
191193
server_kwargs = server_kwargs or {}
192194
server = TestServer(__param, **server_kwargs)

requirements-dev.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r requirements.txt
2+
3+
mypy==1.15.0

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-e .
2+
aiohttp==3.11.17
3+
pytest==8.3.5
4+
pytest-asyncio==0.26.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ setup_requires =
4242

4343
install_requires =
4444
pytest >= 6.1.0
45-
aiohttp >= 3.11.0b0
45+
aiohttp >= 3.11.0
4646
pytest-asyncio >= 0.17.2
4747

4848
[options.extras_require]

0 commit comments

Comments
 (0)