Skip to content

Commit 68a4fad

Browse files
committed
Don't use trio's deprecated warning, add test, add newsfragment
1 parent 1ea6615 commit 68a4fad

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

newsfragments/3322.deprecated.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Implement `trio.Event.__bool__` and have it raise a `DeprecationWarning` and tell users to use `trio.Event.is_set` instead. Would be caught earlier with `mypy --enable-error-code=truthy-bool`, this is for users who don't use mypy.

src/trio/_sync.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
enable_ki_protection,
1717
remove_parking_lot_breaker,
1818
)
19-
from ._depreciate import warn_deprecated
19+
from ._deprecate import warn_deprecated
2020
from ._util import final
2121

2222
if TYPE_CHECKING:
@@ -120,7 +120,6 @@ def __bool__(self) -> True:
120120
"0.30.1",
121121
issue=3238,
122122
instead=self.is_set,
123-
use_triodeprecationwarning=True,
124123
)
125124
return True
126125

src/trio/_tests/test_sync.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ async def test_Event() -> None:
2323
assert not e.is_set()
2424
assert e.statistics().tasks_waiting == 0
2525

26+
with pytest.warns(
27+
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\)",
29+
):
30+
e.__bool__()
31+
2632
e.set()
2733
assert e.is_set()
2834
with assert_checkpoints():

0 commit comments

Comments
 (0)