Skip to content

Commit e9596a2

Browse files
committed
fixes after review
1 parent 0030ac8 commit e9596a2

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

newsfragments/3197.feature.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Add :func:`@trio.as_safe_channel <trio.as_safe_channel>`, a wrapper that can be used to make async generators safe. This will be the suggested fix for `ASYNC900 <https://flake8-async.readthedocs.io/en/latest/rules.html#async900>`_.
1+
Add :func:`@trio.as_safe_channel <trio.as_safe_channel>`, a wrapper that can be used to make async generators safe.
2+
This will be the suggested fix for the flake8-async lint rule `ASYNC900 <https://flake8-async.readthedocs.io/en/latest/rules.html#async900>`_.

src/trio/_tests/test_channel.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -463,23 +463,6 @@ async def agen() -> AsyncGenerator[None]: # pragma: no cover
463463
cs.cancel()
464464

465465

466-
async def test_as_safe_channel_recv_closed(
467-
autojump_clock: trio.testing.MockClock,
468-
) -> None:
469-
event = trio.Event()
470-
471-
@as_safe_channel
472-
async def agen() -> AsyncGenerator[int]:
473-
await event.wait()
474-
yield 1
475-
476-
async with agen() as recv_chan:
477-
await recv_chan.aclose()
478-
event.set()
479-
# wait for agen to try sending on the closed channel
480-
await trio.sleep(1)
481-
482-
483466
async def test_as_safe_channel_no_race() -> None:
484467
# this previously led to a race condition due to
485468
# https://github.com/python-trio/trio/issues/1559
@@ -585,6 +568,7 @@ async def agen() -> AsyncGenerator[None]:
585568
async def test_as_safe_channel_dont_unwrap_user_exceptiongroup() -> None:
586569
@as_safe_channel
587570
async def agen() -> AsyncGenerator[None]:
571+
raise NotImplementedError("not entered")
588572
yield
589573

590574
with RaisesGroup(Matcher(ValueError, match="bar"), match="foo"):
@@ -598,8 +582,8 @@ async def test_as_safe_channel_multiple_receiver() -> None:
598582
@as_safe_channel
599583
async def agen() -> AsyncGenerator[int]:
600584
await event.wait()
601-
for i in range(2):
602-
yield i
585+
yield 0
586+
yield 1
603587

604588
async def handle_value(
605589
recv_chan: trio.abc.ReceiveChannel[int],

0 commit comments

Comments
 (0)