Skip to content

Commit 1ea6615

Browse files
committed
Switch to deprecated warning
1 parent 24a8f08 commit 1ea6615

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/trio/_sync.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import math
4-
from typing import TYPE_CHECKING, NoReturn, Protocol
4+
from typing import TYPE_CHECKING, Protocol
55

66
import attrs
77

@@ -16,6 +16,7 @@
1616
enable_ki_protection,
1717
remove_parking_lot_breaker,
1818
)
19+
from ._depreciate import warn_deprecated
1920
from ._util import final
2021

2122
if TYPE_CHECKING:
@@ -112,11 +113,16 @@ def statistics(self) -> EventStatistics:
112113
"""
113114
return EventStatistics(tasks_waiting=len(self._tasks))
114115

115-
def __bool__(self) -> NoReturn:
116-
"""Raise NotImplementedError."""
117-
raise NotImplementedError(
118-
"Trio events cannot be treated as bools; consider using 'event.is_set()'"
116+
def __bool__(self) -> True:
117+
"""Return True and raise warning."""
118+
warn_deprecated(
119+
self.__bool__,
120+
"0.30.1",
121+
issue=3238,
122+
instead=self.is_set,
123+
use_triodeprecationwarning=True,
119124
)
125+
return True
120126

121127

122128
class _HasAcquireRelease(Protocol):

0 commit comments

Comments
 (0)