Skip to content

Commit 494acf6

Browse files
committed
chore: enable anyio_mode=auto
1 parent bad2cdf commit 494acf6

22 files changed

+12
-91
lines changed

poetry.lock

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

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pydantic = ">=1.0,<=3.0"
3434
importlib-metadata = "*"
3535
pycron = "^3.0.0"
3636
taskiq_dependencies = ">=1.3.1,<2"
37-
anyio = ">=3"
37+
anyio = ">=4"
3838
packaging = ">=19"
3939
# For prometheus metrics
4040
prometheus_client = { version = "^0", optional = true }
@@ -104,6 +104,7 @@ multi_line_output = 3
104104

105105
[tool.pytest.ini_options]
106106
log_level = 'INFO'
107+
anyio_mode = "auto"
107108

108109
[tool.coverage.run]
109110
omit = [
@@ -174,6 +175,7 @@ line-length = 88
174175
"SLF001", # Private member accessed
175176
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
176177
"D101", # Missing docstring in public class
178+
"D102", # Missing docstring in public method
177179
]
178180

179181
[tool.ruff.lint.pydocstyle]

tests/api/test_receiver_task.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from tests.utils import AsyncQueueBroker
88

99

10-
@pytest.mark.anyio
1110
async def test_successful() -> None:
1211
broker = AsyncQueueBroker()
1312
kicked = 0
@@ -28,7 +27,6 @@ def test_func() -> None:
2827
assert kicked == desired_kicked
2928

3029

31-
@pytest.mark.anyio
3230
async def test_cancelation() -> None:
3331
broker = AsyncQueueBroker()
3432
kicked = 0

tests/api/test_scheduler.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
import contextlib
33
from datetime import datetime, timedelta, timezone
44

5-
import pytest
6-
75
from taskiq import TaskiqScheduler
86
from taskiq.api import run_scheduler_task
97
from taskiq.schedule_sources import LabelScheduleSource
108
from tests.utils import AsyncQueueBroker
119

1210

13-
@pytest.mark.anyio
1411
async def test_successful() -> None:
1512
broker = AsyncQueueBroker()
1613
scheduler = TaskiqScheduler(broker, sources=[LabelScheduleSource(broker)])
@@ -26,7 +23,6 @@ def _() -> None:
2623
scheduler_task.cancel()
2724

2825

29-
@pytest.mark.anyio
3026
async def test_cancelation() -> None:
3127
broker = AsyncQueueBroker()
3228
scheduler = TaskiqScheduler(broker, sources=[LabelScheduleSource(broker)])

tests/brokers/test_inmemory.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from taskiq.state import TaskiqState
99

1010

11-
@pytest.mark.anyio
1211
async def test_inmemory_success() -> None:
1312
broker = InMemoryBroker()
1413
test_val = uuid.uuid4().hex
@@ -23,7 +22,6 @@ async def task() -> str:
2322
assert not broker._running_tasks
2423

2524

26-
@pytest.mark.anyio
2725
async def test_cannot_listen() -> None:
2826
broker = InMemoryBroker()
2927

@@ -32,7 +30,6 @@ async def test_cannot_listen() -> None:
3230
pass
3331

3432

35-
@pytest.mark.anyio
3633
async def test_startup() -> None:
3734
broker = InMemoryBroker()
3835
test_value = uuid.uuid4().hex
@@ -51,7 +48,6 @@ async def _c_startup(state: TaskiqState) -> None:
5148
assert broker.state.from_client == test_value
5249

5350

54-
@pytest.mark.anyio
5551
async def test_shutdown() -> None:
5652
broker = InMemoryBroker()
5753
test_value = uuid.uuid4().hex
@@ -70,7 +66,6 @@ async def _c_startup(state: TaskiqState) -> None:
7066
assert broker.state.from_client == test_value
7167

7268

73-
@pytest.mark.anyio
7469
async def test_execution() -> None:
7570
broker = InMemoryBroker()
7671
test_value = uuid.uuid4().hex
@@ -87,7 +82,6 @@ async def test_task() -> str:
8782
assert result.return_value == test_value
8883

8984

90-
@pytest.mark.anyio
9185
async def test_inline_awaits() -> None:
9286
broker = InMemoryBroker(await_inplace=True)
9387
slept = False
@@ -104,7 +98,6 @@ async def test_task() -> None:
10498
assert not broker._running_tasks
10599

106100

107-
@pytest.mark.anyio
108101
async def test_wait_all() -> None:
109102
broker = InMemoryBroker()
110103
slept = False

tests/cli/scheduler/test_updater.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from datetime import datetime
22
from typing import List, Union
33

4-
import pytest
5-
64
from taskiq import InMemoryBroker, ScheduleSource
75
from taskiq.cli.scheduler.run import get_all_schedules
86
from taskiq.scheduler.scheduled_task import ScheduledTask
@@ -20,7 +18,6 @@ async def get_schedules(self) -> List[ScheduledTask]:
2018
return self.schedules
2119

2220

23-
@pytest.mark.anyio
2421
async def test_get_schedules_success() -> None:
2522
"""Tests that schedules are returned correctly."""
2623
schedules1 = [
@@ -62,7 +59,6 @@ async def test_get_schedules_success() -> None:
6259
]
6360

6461

65-
@pytest.mark.anyio
6662
async def test_get_schedules_error() -> None:
6763
"""Tests that if source returned an error, empty list will be returned."""
6864
source1 = DummySource(

tests/depends/test_progress_tracker.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def get_message(
5656
)
5757

5858

59-
@pytest.mark.anyio
6059
@pytest.mark.parametrize(
6160
"state,meta",
6261
[
@@ -82,7 +81,6 @@ async def test_func(tes_val: ProgressTracker[Any] = TaskiqDepends()) -> None:
8281
assert progress.state == state
8382

8483

85-
@pytest.mark.anyio
8684
async def test_progress_tracker_ctx_none() -> None:
8785
broker = InMemoryBroker()
8886

@@ -98,7 +96,6 @@ async def test_func() -> None:
9896
assert progress is None
9997

10098

101-
@pytest.mark.anyio
10299
@pytest.mark.parametrize(
103100
"state,meta",
104101
[

tests/formatters/test_json_formatter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import json
22

3-
import pytest
4-
53
from taskiq.formatters.json_formatter import JSONFormatter
64
from taskiq.message import BrokerMessage, TaskiqMessage
75

86

9-
@pytest.mark.anyio
107
async def test_json_dumps() -> None:
118
fmt = JSONFormatter()
129
msg = TaskiqMessage(
@@ -34,7 +31,6 @@ async def test_json_dumps() -> None:
3431
assert json.loads(dumped.message) == json.loads(expected.message)
3532

3633

37-
@pytest.mark.anyio
3834
async def test_json_loads() -> None:
3935
fmt = JSONFormatter()
4036
msg = (

tests/formatters/test_proxy_formatter.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import pytest
2-
31
from taskiq.brokers.inmemory_broker import InMemoryBroker
42
from taskiq.message import BrokerMessage, TaskiqMessage
53

64

7-
@pytest.mark.anyio
85
async def test_proxy_dumps() -> None:
96
# uses json serializer by default
107
broker = InMemoryBroker()
@@ -29,7 +26,6 @@ async def test_proxy_dumps() -> None:
2926
assert broker.formatter.dumps(msg) == expected
3027

3128

32-
@pytest.mark.anyio
3329
async def test_proxy_loads() -> None:
3430
# uses json serializer by default
3531
broker = InMemoryBroker()

tests/middlewares/test_simple_retry.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def broker() -> AsyncMock:
1717
return mocked_broker
1818

1919

20-
@pytest.mark.anyio
2120
async def test_successful_retry(broker: AsyncMock) -> None:
2221
middleware = SimpleRetryMiddleware()
2322
middleware.set_broker(broker)
@@ -39,7 +38,6 @@ async def test_successful_retry(broker: AsyncMock) -> None:
3938
assert resend.labels["_retries"] == "1"
4039

4140

42-
@pytest.mark.anyio
4341
async def test_no_retry(broker: AsyncMock) -> None:
4442
middleware = SimpleRetryMiddleware()
4543
middleware.set_broker(broker)
@@ -57,7 +55,6 @@ async def test_no_retry(broker: AsyncMock) -> None:
5755
broker.kick.assert_not_called()
5856

5957

60-
@pytest.mark.anyio
6158
async def test_max_retries(broker: AsyncMock) -> None:
6259
middleware = SimpleRetryMiddleware(default_retry_count=3)
6360
middleware.set_broker(broker)

0 commit comments

Comments
 (0)