Skip to content

Commit 3b14df2

Browse files
committed
Add if not TYPE_CHECKING
1 parent 14e16fe commit 3b14df2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/trio/_sync.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,17 @@ def statistics(self) -> EventStatistics:
113113
"""
114114
return EventStatistics(tasks_waiting=len(self._tasks))
115115

116-
def __bool__(self) -> Literal[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-
)
124-
return True
116+
if not TYPE_CHECKING:
117+
118+
def __bool__(self) -> Literal[True]:
119+
"""Return True and raise warning."""
120+
warn_deprecated(
121+
self.__bool__,
122+
"0.31.0",
123+
issue=3238,
124+
instead=self.is_set,
125+
)
126+
return True
125127

126128

127129
class _HasAcquireRelease(Protocol):

src/trio/_tests/test_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def test_Event() -> None:
2525

2626
with pytest.warns(
2727
DeprecationWarning,
28-
match=r"trio\.Event\.__bool__ is deprecated since Trio 0\.30\.1; use trio\.Event\.is_set instead \(https://github.com/python-trio/trio/issues/3238\)",
28+
match=r"trio\.Event\.__bool__ is deprecated since Trio 0\.31\.0; use trio\.Event\.is_set instead \(https://github.com/python-trio/trio/issues/3238\)",
2929
):
3030
e.__bool__()
3131

0 commit comments

Comments
 (0)