python-trio / trio

Trio – a friendly Python library for async concurrency and I/O
https://trio.readthedocs.io
Other
6.12k stars 335 forks source link

Using trio with attrs 24.1.0 raises a warning #3053

Closed pquentin closed 1 month ago

pquentin commented 2 months ago

This happens to break urllib3's CI which, like trio, fails on warnings.

ImportError while loading conftest '/.../urllib3/test/conftest.py'.
test/conftest.py:15: in <module>
    from dummyserver.app import hypercorn_app
dummyserver/app.py:14: in <module>
    import trio
.nox/test-3-12/lib/python3.12/site-packages/trio/__init__.py:23: in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: split
.nox/test-3-12/lib/python3.12/site-packages/trio/_core/__init__.py:9: in <module>
    from ._entry_queue import TrioToken
.nox/test-3-12/lib/python3.12/site-packages/trio/_core/_entry_queue.py:149: in <module>
    @attrs.define(eq=False, hash=False)
.nox/test-3-12/lib/python3.12/site-packages/attr/_next_gen.py:402: in wrap
    return do_it(cls, True)
.nox/test-3-12/lib/python3.12/site-packages/attr/_next_gen.py:348: in do_it
    return attrs(
.nox/test-3-12/lib/python3.12/site-packages/attr/_make.py:1291: in attrs
    warnings.warn(
E   DeprecationWarning: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.
A5rocks commented 1 month ago

Fix was released in https://github.com/python-trio/trio/releases/tag/v0.26.1

pquentin commented 1 month ago

As mentioned by @hynek in https://github.com/python-trio/trio/pull/3054#issuecomment-2268379142, there's at least one missing instance of this problem. I'm now seeing this:

ImportError while loading conftest '/Users/runner/work/urllib3/urllib3/test/conftest.py'.
test/conftest.py:14: in <module>
    from dummyserver.app import hypercorn_app
dummyserver/app.py:14: in <module>
    import trio
.nox/test-3-8/lib/python3.8/site-packages/trio/__init__.py:26: in <module>
    from . import abc, from_thread, lowlevel, socket, to_thread
.nox/test-3-8/lib/python3.8/site-packages/trio/from_thread.py:6: in <module>
    from ._threads import (
.nox/test-3-8/lib/python3.8/site-packages/trio/_threads.py:143: in <module>
    class ThreadPlaceholder:
.nox/test-3-8/lib/python3.8/site-packages/attr/_next_gen.py:402: in wrap
    return do_it(cls, True)
.nox/test-3-8/lib/python3.8/site-packages/attr/_next_gen.py:348: in do_it
    return attrs(
.nox/test-3-8/lib/python3.8/site-packages/attr/_make.py:1291: in attrs
    warnings.warn(
E   DeprecationWarning: The `hash` argument is deprecated in favor of `unsafe_hash` and will be removed in or after August 2025.
A5rocks commented 1 month ago

I'm surprised our CI passed...

A5rocks commented 1 month ago

OK I'm pretty sure this is because when pytest uses a plugin (which we use) it isn't looking for warnings. And then the warning doesn't happen again next time we import.