Skip to content

Commit 17af5a5

Browse files
authored
Fixed return annotation of __aexit__ (#913)
1 parent b7eded9 commit 17af5a5

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

docs/versionhistory.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.
1212
this prevents an OSError on the ``ProactorEventLoop``.
1313
(`#896 <https://github.com/agronholm/anyio/pull/896>`_; PR by @graingert)
1414
- Fixed ``anyio.Path.copy()`` and ``anyio.Path.copy_into()`` failing on Python 3.14.0a7
15+
- Fixed return annotation of ``__aexit__`` on async context managers. CMs which can
16+
suppress exceptions should return ``bool``, or ``None`` otherwise.
17+
(`#913 <https://github.com/agronholm/anyio/pull/913>`_; PR by @Enegg)
1518

1619
**4.9.0**
1720

src/anyio/_backends/_asyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ async def __aexit__(
726726
exc_type: type[BaseException] | None,
727727
exc_val: BaseException | None,
728728
exc_tb: TracebackType | None,
729-
) -> bool | None:
729+
) -> bool:
730730
try:
731731
if exc_val is not None:
732732
self.cancel_scope.cancel()

src/anyio/_core/_synchronization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ async def __aexit__(
505505
exc_type: type[BaseException] | None,
506506
exc_val: BaseException | None,
507507
exc_tb: TracebackType | None,
508-
) -> bool | None:
508+
) -> None:
509509
raise NotImplementedError
510510

511511
@property
@@ -630,7 +630,7 @@ async def __aexit__(
630630
exc_type: type[BaseException] | None,
631631
exc_val: BaseException | None,
632632
exc_tb: TracebackType | None,
633-
) -> bool | None:
633+
) -> None:
634634
return await self._limiter.__aexit__(exc_type, exc_val, exc_tb)
635635

636636
@property

src/anyio/abc/_sockets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def __aexit__(
3535
exc_type: type[BaseException] | None,
3636
exc_val: BaseException | None,
3737
exc_tb: TracebackType | None,
38-
) -> bool | None:
38+
) -> None:
3939
return None
4040

4141

src/anyio/abc/_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ async def __aexit__(
9797
exc_type: type[BaseException] | None,
9898
exc_val: BaseException | None,
9999
exc_tb: TracebackType | None,
100-
) -> bool | None:
100+
) -> bool:
101101
"""Exit the task group context waiting for all tasks to finish."""

src/anyio/from_thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async def __aexit__(
163163
exc_type: type[BaseException] | None,
164164
exc_val: BaseException | None,
165165
exc_tb: TracebackType | None,
166-
) -> bool | None:
166+
) -> bool:
167167
await self.stop()
168168
return await self._task_group.__aexit__(exc_type, exc_val, exc_tb)
169169

0 commit comments

Comments
 (0)