Skip to content

Don't use hash to avoid attrs warning #3054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3053.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switched ``attrs`` usage off of ``hash``, which is now deprecated.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies = [
# attrs 19.2.0 adds `eq` option to decorators
# attrs 20.1.0 adds @frozen
# attrs 21.1.0 adds a dataclass transform for type-checkers
# attrs 21.3.0 adds `import addrs`
# attrs 21.3.0 adds `import attrs`
"attrs >= 23.2.0",
"sortedcontainers",
"idna",
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_entry_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run_sync_soon(


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

Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_io_epoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class _EpollStatistics:
# wanted to about how epoll works.


@attrs.define(eq=False, hash=False)
@attrs.define(eq=False)
class EpollIOManager:
# Using lambda here because otherwise crash on import with gevent monkey patching
# See https://github.com/python-trio/trio/issues/2848
Expand Down
4 changes: 2 additions & 2 deletions src/trio/_core/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class _NoValue: ...


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


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

Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_parking_lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ParkingLotStatistics:


@final
@attrs.define(eq=False, hash=False)
@attrs.define(eq=False)
class ParkingLot:
"""A fair wait queue with cancellation and requeueing.

Expand Down
8 changes: 4 additions & 4 deletions src/trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def started(self, value: StatusT_contra | None = None) -> None:

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


@final
@attrs.define(eq=False, hash=False, repr=False)
@attrs.define(eq=False, repr=False)
class Task(metaclass=NoPublicConstructor):
_parent_nursery: Nursery | None
coro: Coroutine[Any, Outcome[object], Any]
Expand Down Expand Up @@ -1532,7 +1532,7 @@ class RunStatistics:
# worker thread.


@attrs.define(eq=False, hash=False)
@attrs.define(eq=False)
class GuestState:
runner: Runner
run_sync_soon_threadsafe: Callable[[Callable[[], object]], object]
Expand Down Expand Up @@ -1582,7 +1582,7 @@ def in_main_thread() -> None:
start_thread_soon(get_events, deliver)


@attrs.define(eq=False, hash=False)
@attrs.define(eq=False)
class Runner:
clock: Clock
instruments: Instruments
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_core/_tests/test_instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ...lowlevel import Task


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

Expand Down
2 changes: 1 addition & 1 deletion src/trio/_highlevel_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _is_halfclosable(stream: SendStream) -> TypeGuard[HalfCloseableStream]:


@final
@attrs.define(eq=False, hash=False, slots=False)
@attrs.define(eq=False, slots=False)
class StapledStream(
HalfCloseableStream,
Generic[SendStreamT, ReceiveStreamT],
Expand Down
4 changes: 2 additions & 2 deletions src/trio/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EventStatistics:


@final
@attrs.define(repr=False, eq=False, hash=False)
@attrs.define(repr=False, eq=False)
class Event:
"""A waitable boolean value useful for inter-task synchronization,
inspired by :class:`threading.Event`.
Expand Down Expand Up @@ -538,7 +538,7 @@ class LockStatistics:
tasks_waiting: int


@attrs.define(eq=False, hash=False, repr=False, slots=False)
@attrs.define(eq=False, repr=False, slots=False)
class _LockImpl(AsyncContextManagerMixin):
_lot: ParkingLot = attrs.field(factory=ParkingLot, init=False)
_owner: Task | None = attrs.field(default=None, init=False)
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_highlevel_serve_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
StapledMemoryStream = StapledStream[MemorySendStream, MemoryReceiveStream]


@attrs.define(hash=False, eq=False, slots=False)
@attrs.define(eq=False, slots=False)
class MemoryListener(trio.abc.Listener[StapledMemoryStream]):
closed: bool = False
accepted_streams: list[trio.abc.Stream] = attrs.Factory(list)
Expand Down
2 changes: 1 addition & 1 deletion src/trio/testing/_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@_util.final
@attrs.define(eq=False, hash=False, slots=False)
@attrs.define(eq=False, slots=False)
class Sequencer:
"""A convenience class for forcing code in different tasks to run in an
explicit linear order.
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ astroid==3.2.2
# via pylint
async-generator==1.10
# via -r test-requirements.in
attrs==23.2.0
attrs==24.1.0
# via
# -r test-requirements.in
# outcome
Expand Down
Loading