Skip to content

Commit e813d15

Browse files
committed
Remove deprecated features
1 parent 5da94bf commit e813d15

File tree

4 files changed

+6
-87
lines changed

4 files changed

+6
-87
lines changed

src/trio/_highlevel_open_tcp_listeners.py

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

33
import errno
4-
import math
54
import sys
65
from typing import TYPE_CHECKING
76

87
import trio
98
from trio import TaskStatus
109

1110
from . import socket as tsocket
12-
from ._deprecate import warn_deprecated
1311

1412
if TYPE_CHECKING:
1513
from collections.abc import Awaitable, Callable
@@ -49,15 +47,6 @@ def _compute_backlog(backlog: int | None) -> int:
4947
# Many systems (Linux, BSDs, ...) store the backlog in a uint16 and are
5048
# missing overflow protection, so we apply our own overflow protection.
5149
# https://github.com/golang/go/issues/5030
52-
if backlog == math.inf:
53-
backlog = None
54-
warn_deprecated(
55-
thing="math.inf as a backlog",
56-
version="0.23.0",
57-
instead="None",
58-
issue=2842,
59-
use_triodeprecationwarning=True,
60-
)
6150
if not isinstance(backlog, int) and backlog is not None:
6251
raise TypeError(f"backlog must be an int or None, not {backlog!r}")
6352
if backlog is None:

src/trio/_tests/test_highlevel_open_tcp_listeners.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import trio
1313
from trio import (
1414
SocketListener,
15-
TrioDeprecationWarning,
1615
open_tcp_listeners,
1716
open_tcp_stream,
1817
serve_tcp,
@@ -387,17 +386,6 @@ async def test_open_tcp_listeners_backlog() -> None:
387386
assert listener.socket.backlog == expected # type: ignore[attr-defined]
388387

389388

390-
async def test_open_tcp_listeners_backlog_inf_warning() -> None:
391-
fsf = FakeSocketFactory(99)
392-
tsocket.set_custom_socket_factory(fsf)
393-
with pytest.warns(TrioDeprecationWarning):
394-
listeners = await open_tcp_listeners(0, backlog=float("inf")) # type: ignore[arg-type]
395-
assert listeners
396-
for listener in listeners:
397-
# `backlog` only exists on FakeSocket
398-
assert listener.socket.backlog == 0xFFFF # type: ignore[attr-defined]
399-
400-
401389
async def test_open_tcp_listeners_backlog_float_error() -> None:
402390
fsf = FakeSocketFactory(99)
403391
tsocket.set_custom_socket_factory(fsf)

src/trio/_tests/test_threads.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
CancelScope,
2929
CapacityLimiter,
3030
Event,
31-
TrioDeprecationWarning,
3231
_core,
3332
fail_after,
3433
move_on_after,
@@ -574,7 +573,7 @@ def release_on_behalf_of(self, borrower: Task) -> None:
574573

575574
# TODO: should CapacityLimiter have an abc or protocol so users can modify it?
576575
# because currently it's `final` so writing code like this is not allowed.
577-
await to_thread_run_sync(lambda: None, limiter=CustomLimiter()) # type: ignore[call-overload]
576+
await to_thread_run_sync(lambda: None, limiter=CustomLimiter()) # type: ignore[arg-type]
578577
assert record == ["acquire", "release"]
579578

580579

@@ -592,7 +591,7 @@ def release_on_behalf_of(self, borrower: Task) -> NoReturn:
592591
bs = BadCapacityLimiter()
593592

594593
with pytest.raises(ValueError, match="^release on behalf$") as excinfo:
595-
await to_thread_run_sync(lambda: None, limiter=bs) # type: ignore[call-overload]
594+
await to_thread_run_sync(lambda: None, limiter=bs) # type: ignore[arg-type]
596595
assert excinfo.value.__context__ is None
597596
assert record == ["acquire", "release"]
598597
record = []
@@ -601,7 +600,7 @@ def release_on_behalf_of(self, borrower: Task) -> NoReturn:
601600
# chains with it
602601
d: dict[str, object] = {}
603602
with pytest.raises(ValueError, match="^release on behalf$") as excinfo:
604-
await to_thread_run_sync(lambda: d["x"], limiter=bs) # type: ignore[call-overload]
603+
await to_thread_run_sync(lambda: d["x"], limiter=bs) # type: ignore[arg-type]
605604
assert isinstance(excinfo.value.__context__, KeyError)
606605
assert record == ["acquire", "release"]
607606

@@ -911,7 +910,7 @@ def __bool__(self) -> bool:
911910
raise NotImplementedError
912911

913912
with pytest.raises(NotImplementedError):
914-
await to_thread_run_sync(int, abandon_on_cancel=BadBool()) # type: ignore[call-overload]
913+
await to_thread_run_sync(int, abandon_on_cancel=BadBool()) # type: ignore[arg-type]
915914

916915

917916
async def test_from_thread_reuses_task() -> None:
@@ -1098,28 +1097,6 @@ async def child() -> None:
10981097
nursery.start_soon(child)
10991098

11001099

1101-
async def test_cancellable_and_abandon_raises() -> None:
1102-
with pytest.raises(
1103-
ValueError,
1104-
match=r"^Cannot set `cancellable` and `abandon_on_cancel` simultaneously\.$",
1105-
):
1106-
await to_thread_run_sync(bool, cancellable=True, abandon_on_cancel=False) # type: ignore[call-overload]
1107-
1108-
with pytest.raises(
1109-
ValueError,
1110-
match=r"^Cannot set `cancellable` and `abandon_on_cancel` simultaneously\.$",
1111-
):
1112-
await to_thread_run_sync(bool, cancellable=True, abandon_on_cancel=True) # type: ignore[call-overload]
1113-
1114-
1115-
async def test_cancellable_warns() -> None:
1116-
with pytest.warns(TrioDeprecationWarning):
1117-
await to_thread_run_sync(bool, cancellable=False)
1118-
1119-
with pytest.warns(TrioDeprecationWarning):
1120-
await to_thread_run_sync(bool, cancellable=True)
1121-
1122-
11231100
async def test_wait_all_threads_completed() -> None:
11241101
no_threads_left = False
11251102
e1 = Event()

src/trio/_threads.py

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import queue as stdlib_queue
77
import threading
88
from itertools import count
9-
from typing import TYPE_CHECKING, Generic, TypeVar, overload
9+
from typing import TYPE_CHECKING, Generic, TypeVar
1010

1111
import attrs
1212
import outcome
@@ -23,7 +23,6 @@
2323
enable_ki_protection,
2424
start_thread_soon,
2525
)
26-
from ._deprecate import warn_deprecated
2726
from ._sync import CapacityLimiter, Event
2827
from ._util import coroutine_or_error
2928

@@ -244,33 +243,12 @@ def run_in_system_nursery(self, token: TrioToken) -> None:
244243
token.run_sync_soon(self.run_sync)
245244

246245

247-
@overload # Decorator used on function with Coroutine[Any, Any, RetT]
248-
async def to_thread_run_sync( # type: ignore[misc]
249-
sync_fn: Callable[..., RetT],
250-
*args: object,
251-
thread_name: str | None = None,
252-
abandon_on_cancel: bool = False,
253-
limiter: CapacityLimiter | None = None,
254-
) -> RetT: ...
255-
256-
257-
@overload # Decorator used on function with Coroutine[Any, Any, RetT]
258-
async def to_thread_run_sync( # type: ignore[misc]
259-
sync_fn: Callable[..., RetT],
260-
*args: object,
261-
thread_name: str | None = None,
262-
cancellable: bool = False,
263-
limiter: CapacityLimiter | None = None,
264-
) -> RetT: ...
265-
266-
267246
@enable_ki_protection # Decorator used on function with Coroutine[Any, Any, RetT]
268247
async def to_thread_run_sync( # type: ignore[misc]
269248
sync_fn: Callable[..., RetT],
270249
*args: object,
271250
thread_name: str | None = None,
272-
abandon_on_cancel: bool | None = None,
273-
cancellable: bool | None = None,
251+
abandon_on_cancel: bool = False,
274252
limiter: CapacityLimiter | None = None,
275253
) -> RetT:
276254
"""Convert a blocking operation into an async operation using a thread.
@@ -357,19 +335,6 @@ async def to_thread_run_sync( # type: ignore[misc]
357335
358336
"""
359337
await trio.lowlevel.checkpoint_if_cancelled()
360-
if cancellable is not None:
361-
if abandon_on_cancel is not None:
362-
raise ValueError(
363-
"Cannot set `cancellable` and `abandon_on_cancel` simultaneously."
364-
)
365-
warn_deprecated(
366-
"The `cancellable=` keyword argument to `trio.to_thread.run_sync`",
367-
"0.23.0",
368-
issue=2841,
369-
instead="`abandon_on_cancel=`",
370-
use_triodeprecationwarning=True,
371-
)
372-
abandon_on_cancel = cancellable
373338
# raise early if abandon_on_cancel.__bool__ raises
374339
# and give a new name to ensure mypy knows it's never None
375340
abandon_bool = bool(abandon_on_cancel)

0 commit comments

Comments
 (0)