Skip to content

Commit cabdd9f

Browse files
authored
Merge pull request #1726 from pquentin/remove-deprecated-subclassing
Stop allowing subclassing public classes
2 parents 8a1178b + 397f67e commit cabdd9f

16 files changed

Lines changed: 32 additions & 60 deletions

newsfragments/1726.deprecated.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stop allowing subclassing public classes. This behavior was deprecated in 0.15.0.

trio/_core/_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Runvar implementations
22
from . import _run
33

4-
from .._util import SubclassingDeprecatedIn_v0_15_0
4+
from .._util import Final
55

66

77
class _RunVarToken:
@@ -19,7 +19,7 @@ def __init__(self, var, value):
1919
self.redeemed = False
2020

2121

22-
class RunVar(metaclass=SubclassingDeprecatedIn_v0_15_0):
22+
class RunVar(metaclass=Final):
2323
"""The run-local variant of a context variable.
2424
2525
:class:`RunVar` objects are similar to context variable objects,

trio/_core/_mock_clock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .. import _core
55
from ._run import GLOBAL_RUN_CONTEXT
66
from .._abc import Clock
7-
from .._util import SubclassingDeprecatedIn_v0_15_0
7+
from .._util import Final
88

99
################################################################
1010
# The glorious MockClock
@@ -14,7 +14,7 @@
1414
# Prior art:
1515
# https://twistedmatrix.com/documents/current/api/twisted.internet.task.Clock.html
1616
# https://github.com/ztellman/manifold/issues/57
17-
class MockClock(Clock, metaclass=SubclassingDeprecatedIn_v0_15_0):
17+
class MockClock(Clock, metaclass=Final):
1818
"""A user-controllable clock suitable for writing tests.
1919
2020
Args:

trio/_core/_parking_lot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
from collections import OrderedDict
7676

7777
from .. import _core
78-
from .._util import SubclassingDeprecatedIn_v0_15_0
78+
from .._util import Final
7979

8080
_counter = count()
8181

@@ -86,7 +86,7 @@ class _ParkingLotStatistics:
8686

8787

8888
@attr.s(eq=False, hash=False)
89-
class ParkingLot(metaclass=SubclassingDeprecatedIn_v0_15_0):
89+
class ParkingLot(metaclass=Final):
9090
"""A fair wait queue with cancellation and requeueing.
9191
9292
This class encapsulates the tricky parts of implementing a wait

trio/_core/_unbounded_queue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from .. import _core
44
from .._deprecate import deprecated
5-
from .._util import SubclassingDeprecatedIn_v0_15_0
5+
from .._util import Final
66

77

88
@attr.s(frozen=True)
@@ -11,7 +11,7 @@ class _UnboundedQueueStats:
1111
tasks_waiting = attr.ib()
1212

1313

14-
class UnboundedQueue(metaclass=SubclassingDeprecatedIn_v0_15_0):
14+
class UnboundedQueue(metaclass=Final):
1515
"""An unbounded queue suitable for certain unusual forms of inter-task
1616
communication.
1717

trio/_highlevel_generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import trio
44
from .abc import HalfCloseableStream
55

6-
from trio._util import SubclassingDeprecatedIn_v0_15_0
6+
from trio._util import Final
77

88

99
async def aclose_forcefully(resource):
@@ -37,7 +37,7 @@ async def aclose_forcefully(resource):
3737

3838

3939
@attr.s(eq=False, hash=False)
40-
class StapledStream(HalfCloseableStream, metaclass=SubclassingDeprecatedIn_v0_15_0):
40+
class StapledStream(HalfCloseableStream, metaclass=Final):
4141
"""This class `staples <https://en.wikipedia.org/wiki/Staple_(fastener)>`__
4242
together two unidirectional streams to make single bidirectional stream.
4343

trio/_highlevel_socket.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import trio
77
from . import socket as tsocket
8-
from ._util import ConflictDetector, SubclassingDeprecatedIn_v0_15_0
8+
from ._util import ConflictDetector, Final
99
from .abc import HalfCloseableStream, Listener
1010

1111
# XX TODO: this number was picked arbitrarily. We should do experiments to
@@ -35,7 +35,7 @@ def _translate_socket_errors_to_stream_errors():
3535
) from exc
3636

3737

38-
class SocketStream(HalfCloseableStream, metaclass=SubclassingDeprecatedIn_v0_15_0):
38+
class SocketStream(HalfCloseableStream, metaclass=Final):
3939
"""An implementation of the :class:`trio.abc.HalfCloseableStream`
4040
interface based on a raw network socket.
4141
@@ -315,7 +315,7 @@ def getsockopt(self, level, option, buffersize=0):
315315
pass
316316

317317

318-
class SocketListener(Listener[SocketStream], metaclass=SubclassingDeprecatedIn_v0_15_0):
318+
class SocketListener(Listener[SocketStream], metaclass=Final):
319319
"""A :class:`~trio.abc.Listener` that uses a listening socket to accept
320320
incoming connections as :class:`SocketStream` objects.
321321

trio/_path.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pathlib
77

88
import trio
9-
from trio._util import async_wraps, SubclassingDeprecatedIn_v0_15_0
9+
from trio._util import async_wraps, Final
1010

1111

1212
# re-wrap return value from methods that return new instances of pathlib.Path
@@ -77,7 +77,7 @@ async def wrapper(cls, *args, **kwargs):
7777
return wrapper
7878

7979

80-
class AsyncAutoWrapperType(SubclassingDeprecatedIn_v0_15_0):
80+
class AsyncAutoWrapperType(Final):
8181
def __init__(cls, name, bases, attrs):
8282
super().__init__(name, bases, attrs)
8383

trio/_ssl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
from .abc import Stream, Listener
159159
from ._highlevel_generic import aclose_forcefully
160160
from . import _sync
161-
from ._util import ConflictDetector, SubclassingDeprecatedIn_v0_15_0
161+
from ._util import ConflictDetector, Final
162162
from ._deprecate import warn_deprecated
163163

164164
################################################################
@@ -224,7 +224,7 @@ def done(self):
224224
_State = _Enum("_State", ["OK", "BROKEN", "CLOSED"])
225225

226226

227-
class SSLStream(Stream, metaclass=SubclassingDeprecatedIn_v0_15_0):
227+
class SSLStream(Stream, metaclass=Final):
228228
r"""Encrypted communication using SSL/TLS.
229229
230230
:class:`SSLStream` wraps an arbitrary :class:`~trio.abc.Stream`, and
@@ -870,7 +870,7 @@ async def wait_send_all_might_not_block(self):
870870
await self.transport_stream.wait_send_all_might_not_block()
871871

872872

873-
class SSLListener(Listener[SSLStream], metaclass=SubclassingDeprecatedIn_v0_15_0):
873+
class SSLListener(Listener[SSLStream], metaclass=Final):
874874
"""A :class:`~trio.abc.Listener` for SSL/TLS-encrypted servers.
875875
876876
:class:`SSLListener` wraps around another Listener, and converts

trio/_sync.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
from ._core import enable_ki_protection, ParkingLot
99
from ._deprecate import deprecated
10-
from ._util import SubclassingDeprecatedIn_v0_15_0
10+
from ._util import Final
1111

1212

1313
@attr.s(repr=False, eq=False, hash=False)
14-
class Event(metaclass=SubclassingDeprecatedIn_v0_15_0):
14+
class Event(metaclass=Final):
1515
"""A waitable boolean value useful for inter-task synchronization,
1616
inspired by :class:`threading.Event`.
1717
@@ -99,7 +99,7 @@ class _CapacityLimiterStatistics:
9999

100100

101101
@async_cm
102-
class CapacityLimiter(metaclass=SubclassingDeprecatedIn_v0_15_0):
102+
class CapacityLimiter(metaclass=Final):
103103
"""An object for controlling access to a resource with limited capacity.
104104
105105
Sometimes you need to put a limit on how many tasks can do something at
@@ -342,7 +342,7 @@ def statistics(self):
342342

343343

344344
@async_cm
345-
class Semaphore(metaclass=SubclassingDeprecatedIn_v0_15_0):
345+
class Semaphore(metaclass=Final):
346346
"""A `semaphore <https://en.wikipedia.org/wiki/Semaphore_(programming)>`__.
347347
348348
A semaphore holds an integer value, which can be incremented by
@@ -562,7 +562,7 @@ def statistics(self):
562562
)
563563

564564

565-
class Lock(_LockImpl, metaclass=SubclassingDeprecatedIn_v0_15_0):
565+
class Lock(_LockImpl, metaclass=Final):
566566
"""A classic `mutex
567567
<https://en.wikipedia.org/wiki/Lock_(computer_science)>`__.
568568
@@ -576,7 +576,7 @@ class Lock(_LockImpl, metaclass=SubclassingDeprecatedIn_v0_15_0):
576576
"""
577577

578578

579-
class StrictFIFOLock(_LockImpl, metaclass=SubclassingDeprecatedIn_v0_15_0):
579+
class StrictFIFOLock(_LockImpl, metaclass=Final):
580580
r"""A variant of :class:`Lock` where tasks are guaranteed to acquire the
581581
lock in strict first-come-first-served order.
582582
@@ -646,7 +646,7 @@ class _ConditionStatistics:
646646

647647

648648
@async_cm
649-
class Condition(metaclass=SubclassingDeprecatedIn_v0_15_0):
649+
class Condition(metaclass=Final):
650650
"""A classic `condition variable
651651
<https://en.wikipedia.org/wiki/Monitor_(synchronization)>`__, similar to
652652
:class:`threading.Condition`.

0 commit comments

Comments
 (0)