We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
trio.Event.__bool__()
1 parent 77dd921 commit a97f905Copy full SHA for a97f905
src/trio/_sync.py
@@ -1,7 +1,7 @@
1
from __future__ import annotations
2
3
import math
4
-from typing import TYPE_CHECKING, Protocol
+from typing import TYPE_CHECKING, NoReturn, Protocol
5
6
import attrs
7
@@ -112,6 +112,14 @@ def statistics(self) -> EventStatistics:
112
"""
113
return EventStatistics(tasks_waiting=len(self._tasks))
114
115
+ if not TYPE_CHECKING:
116
+
117
+ def __bool__(self) -> NoReturn:
118
+ """Raise NotImplementedError."""
119
+ raise NotImplementedError(
120
+ "Trio events cannot be treated as bools; consider using 'event.is_set()'"
121
+ )
122
123
124
class _HasAcquireRelease(Protocol):
125
"""Only classes with acquire() and release() can use the mixin's implementations."""
0 commit comments