Skip to content

Commit b2e6742

Browse files
authored
Merge pull request #22 from taskiq-python/feature/deps-update
2 parents c7ef231 + 34d5554 commit b2e6742

File tree

8 files changed

+889
-965
lines changed

8 files changed

+889
-965
lines changed

.flake8

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

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ repos:
3333

3434
- id: ruff
3535
name: Run ruff lints
36-
entry: poetry run ruff
36+
entry: poetry run ruff check
3737
language: system
3838
pass_filenames: false
3939
types: [python]

aiohttp_deps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Project was generated using taskiq."""
2+
23
from taskiq_dependencies import Depends
34

45
from aiohttp_deps.initializer import init

poetry.lock

Lines changed: 830 additions & 805 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,20 @@ python = "^3.8.1"
2828
aiohttp = ">=3.9.0,<4"
2929
taskiq-dependencies = ">=1.3.1,<2"
3030
pydantic = "^2"
31-
deepmerge = "^1.1.0"
31+
deepmerge = "^2"
3232

3333
[tool.poetry.group.dev.dependencies]
34-
pytest = "^7.1.2"
34+
pytest = "^8"
3535
mypy = "^1"
36-
pre-commit = "^2.20.0"
37-
coverage = "^6.4.2"
38-
pytest-cov = "^3.0.0"
39-
mock = "^4.0.3"
40-
anyio = "^3.6.1"
41-
pytest-xdist = { version = "^2.5.0", extras = ["psutil"] }
42-
types-mock = "^4.0.15"
43-
black = "^23.1.0"
44-
pytest-aiohttp = "^1.0.4"
45-
ruff = "^0.1.7"
36+
pre-commit = "^3"
37+
coverage = "^7"
38+
pytest-cov = "^5.0.0"
39+
mock = "^5"
40+
anyio = "^4"
41+
pytest-xdist = { version = "^3", extras = ["psutil"] }
42+
types-mock = "^5"
43+
black = "^24"
44+
ruff = "^0.6"
4645

4746
[tool.mypy]
4847
strict = true
@@ -60,7 +59,7 @@ multi_line_output = 3
6059
[tool.ruff]
6160
# List of enabled rulsets.
6261
# See https://docs.astral.sh/ruff/rules/ for more information.
63-
select = [
62+
lint.select = [
6463
"E", # Error
6564
"F", # Pyflakes
6665
"W", # Pycodestyle
@@ -87,7 +86,7 @@ select = [
8786
"PL", # PyLint checks
8887
"RUF", # Specific to Ruff checks
8988
]
90-
ignore = [
89+
lint.ignore = [
9190
"D105", # Missing docstring in magic method
9291
"D107", # Missing docstring in __init__
9392
"D212", # Multi-line docstring summary should start at the first line
@@ -103,10 +102,10 @@ ignore = [
103102

104103
]
105104
exclude = [".venv/"]
106-
mccabe = { max-complexity = 10 }
105+
lint.mccabe = { max-complexity = 10 }
107106
line-length = 88
108107

109-
[tool.ruff.per-file-ignores]
108+
[tool.ruff.lint.per-file-ignores]
110109
"tests/*" = [
111110
"S101", # Use of assert detected
112111
"S301", # Use of pickle detected
@@ -116,14 +115,14 @@ line-length = 88
116115
"D101", # Missing docstring in public class
117116
]
118117

119-
[tool.ruff.pydocstyle]
118+
[tool.ruff.lint.pydocstyle]
120119
convention = "pep257"
121120
ignore-decorators = ["typing.overload"]
122121

123-
[tool.ruff.pylint]
122+
[tool.ruff.lint.pylint]
124123
allow-magic-value-types = ["int", "str", "float"]
125124

126-
[tool.ruff.flake8-bugbear]
125+
[tool.ruff.lint.flake8-bugbear]
127126
extend-immutable-calls = [
128127
"taskiq_dependencies.Depends",
129128
"aiohttp_deps.Depends",

tests/conftest.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from typing import Awaitable, Callable, Union
1+
import asyncio
2+
from typing import AsyncGenerator, Awaitable, Callable, Optional, Union
23

34
import pytest
45
from aiohttp import web
5-
from aiohttp.test_utils import BaseTestServer, TestClient
6+
from aiohttp.test_utils import BaseTestServer, TestClient, TestServer
67

78
from aiohttp_deps import init
89

@@ -28,3 +29,32 @@ def my_app() -> web.Application:
2829
app = web.Application()
2930
app.on_startup.append(init)
3031
return app
32+
33+
34+
@pytest.fixture
35+
async def aiohttp_client() -> (
36+
AsyncGenerator[Callable[[web.Application], Awaitable[TestClient]], None]
37+
):
38+
"""
39+
Create a test client.
40+
41+
This function creates a TestServer
42+
and a test client for the application.
43+
44+
:param app: current application.
45+
:yield: ready to use client.
46+
"""
47+
client: Optional[TestClient] = None
48+
49+
async def inner(app: web.Application) -> TestClient:
50+
nonlocal client
51+
loop = asyncio.get_running_loop()
52+
server = TestServer(app)
53+
client = TestClient(server, loop=loop)
54+
await client.start_server()
55+
return client
56+
57+
yield inner
58+
59+
if client is not None:
60+
await client.close()

tests/test_form.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from io import BytesIO
2+
13
import pydantic
24
import pytest
35
from aiohttp import web
@@ -27,7 +29,7 @@ async def handler(my_form: InputSchema = Depends(Form())) -> web.Response:
2729
client = await aiohttp_client(my_app)
2830
resp = await client.post(
2931
"/",
30-
data={"id": "1", "file": b"bytes"},
32+
data={"id": "1", "file": BytesIO(file_data)},
3133
)
3234
assert resp.status == 200
3335
assert await resp.content.read() == file_data
@@ -61,7 +63,7 @@ async def handler(_: InputSchema = Depends(Form())) -> None:
6163
my_app.router.add_post("/", handler)
6264

6365
client = await aiohttp_client(my_app)
64-
resp = await client.post("/", data={"id": "meme", "file": b""})
66+
resp = await client.post("/", data={"id": "meme", "file": BytesIO(b"")})
6567
assert resp.status == 400
6668

6769

@@ -77,6 +79,6 @@ async def handler(form=Depends(Form())) -> web.Response: # noqa: ANN001
7779

7880
form_data = b"meme"
7981
client = await aiohttp_client(my_app)
80-
resp = await client.post("/", data={"id": "meme", "file": form_data})
82+
resp = await client.post("/", data={"id": "meme", "file": BytesIO(form_data)})
8183
assert resp.status == 200
8284
assert await resp.content.read() == form_data

tests/test_swagger.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ async def my_handler(my_var=Depends(Form())) -> None: # noqa: ANN001
533533
resp_json = await resp.json()
534534
handler_info = resp_json["paths"]["/a"]["get"]
535535
assert (
536-
{}
537-
== handler_info["requestBody"]["content"]["application/x-www-form-urlencoded"]
536+
handler_info["requestBody"]["content"]["application/x-www-form-urlencoded"]
537+
== {}
538538
)
539539

540540

0 commit comments

Comments
 (0)