Skip to content

Commit 8e38a1e

Browse files
authored
Don't use hash to avoid attrs warning (#3054)
1 parent 2d0824f commit 8e38a1e

13 files changed

Lines changed: 18 additions & 17 deletions

newsfragments/3053.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Switched ``attrs`` usage off of ``hash``, which is now deprecated.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencies = [
4040
# attrs 19.2.0 adds `eq` option to decorators
4141
# attrs 20.1.0 adds @frozen
4242
# attrs 21.1.0 adds a dataclass transform for type-checkers
43-
# attrs 21.3.0 adds `import addrs`
43+
# attrs 21.3.0 adds `import attrs`
4444
"attrs >= 23.2.0",
4545
"sortedcontainers",
4646
"idna",

src/trio/_core/_entry_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def run_sync_soon(
146146

147147

148148
@final
149-
@attrs.define(eq=False, hash=False)
149+
@attrs.define(eq=False)
150150
class TrioToken(metaclass=NoPublicConstructor):
151151
"""An opaque object representing a single call to :func:`trio.run`.
152152

src/trio/_core/_io_epoll.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class _EpollStatistics:
198198
# wanted to about how epoll works.
199199

200200

201-
@attrs.define(eq=False, hash=False)
201+
@attrs.define(eq=False)
202202
class EpollIOManager:
203203
# Using lambda here because otherwise crash on import with gevent monkey patching
204204
# See https://github.com/python-trio/trio/issues/2848

src/trio/_core/_local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class _NoValue: ...
1616

1717

1818
@final
19-
@attrs.define(eq=False, hash=False)
19+
@attrs.define(eq=False)
2020
class RunVarToken(Generic[T], metaclass=NoPublicConstructor):
2121
_var: RunVar[T]
2222
previous_value: T | type[_NoValue] = _NoValue
@@ -28,7 +28,7 @@ def _empty(cls, var: RunVar[T]) -> RunVarToken[T]:
2828

2929

3030
@final
31-
@attrs.define(eq=False, hash=False, repr=False)
31+
@attrs.define(eq=False, repr=False)
3232
class RunVar(Generic[T]):
3333
"""The run-local variant of a context variable.
3434

src/trio/_core/_parking_lot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ParkingLotStatistics:
101101

102102

103103
@final
104-
@attrs.define(eq=False, hash=False)
104+
@attrs.define(eq=False)
105105
class ParkingLot:
106106
"""A fair wait queue with cancellation and requeueing.
107107

src/trio/_core/_run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ def started(self, value: StatusT_contra | None = None) -> None:
845845

846846
# This code needs to be read alongside the code from Nursery.start to make
847847
# sense.
848-
@attrs.define(eq=False, hash=False, repr=False, slots=False)
848+
@attrs.define(eq=False, repr=False, slots=False)
849849
class _TaskStatus(TaskStatus[StatusT]):
850850
_old_nursery: Nursery
851851
_new_nursery: Nursery
@@ -1289,7 +1289,7 @@ def __del__(self) -> None:
12891289

12901290

12911291
@final
1292-
@attrs.define(eq=False, hash=False, repr=False)
1292+
@attrs.define(eq=False, repr=False)
12931293
class Task(metaclass=NoPublicConstructor):
12941294
_parent_nursery: Nursery | None
12951295
coro: Coroutine[Any, Outcome[object], Any]
@@ -1532,7 +1532,7 @@ class RunStatistics:
15321532
# worker thread.
15331533

15341534

1535-
@attrs.define(eq=False, hash=False)
1535+
@attrs.define(eq=False)
15361536
class GuestState:
15371537
runner: Runner
15381538
run_sync_soon_threadsafe: Callable[[Callable[[], object]], object]
@@ -1582,7 +1582,7 @@ def in_main_thread() -> None:
15821582
start_thread_soon(get_events, deliver)
15831583

15841584

1585-
@attrs.define(eq=False, hash=False)
1585+
@attrs.define(eq=False)
15861586
class Runner:
15871587
clock: Clock
15881588
instruments: Instruments

src/trio/_core/_tests/test_instrumentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ...lowlevel import Task
1313

1414

15-
@attrs.define(eq=False, hash=False, slots=False)
15+
@attrs.define(eq=False, slots=False)
1616
class TaskRecorder(_abc.Instrument):
1717
record: list[tuple[str, Task | None]] = attrs.Factory(list)
1818

src/trio/_highlevel_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _is_halfclosable(stream: SendStream) -> TypeGuard[HalfCloseableStream]:
5353

5454

5555
@final
56-
@attrs.define(eq=False, hash=False, slots=False)
56+
@attrs.define(eq=False, slots=False)
5757
class StapledStream(
5858
HalfCloseableStream,
5959
Generic[SendStreamT, ReceiveStreamT],

src/trio/_sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class EventStatistics:
3333

3434

3535
@final
36-
@attrs.define(repr=False, eq=False, hash=False)
36+
@attrs.define(repr=False, eq=False)
3737
class Event:
3838
"""A waitable boolean value useful for inter-task synchronization,
3939
inspired by :class:`threading.Event`.
@@ -538,7 +538,7 @@ class LockStatistics:
538538
tasks_waiting: int
539539

540540

541-
@attrs.define(eq=False, hash=False, repr=False, slots=False)
541+
@attrs.define(eq=False, repr=False, slots=False)
542542
class _LockImpl(AsyncContextManagerMixin):
543543
_lot: ParkingLot = attrs.field(factory=ParkingLot, init=False)
544544
_owner: Task | None = attrs.field(default=None, init=False)

0 commit comments

Comments
 (0)