1

The following testcase gives a warning:

import trio, httpx

async def amain():
    async with httpx.AsyncClient() as client:
        r = await client.get('https://icanhazip.com/')
        print(r.text)

trio.run(amain)

Output:

> python  test.py

/path/to/.venv/lib/python3.10/site-packages/anyio/_backends/_trio.py:164: 
TrioDeprecationWarning: trio.MultiError is deprecated since Trio 0.22.0; 
use BaseExceptionGroup (on Python 3.11 and later) or exceptiongroup.BaseExceptionGroup
(earlier versions) instead (https://github.com/python-trio/trio/issues/2211)

  class ExceptionGroup(BaseExceptionGroup, trio.MultiError):
193.37.32.201

Fresh .venv using latest Python (installed with latest pyenv (installed with up-to-date brew)).

pip show trio reports 0.22.0. pip show httpx reports 0.23.0. Both of these are latest releases on pypi.

What's going on here? And how to silence the warning?

P i
  • 29,020
  • 36
  • 159
  • 267

1 Answers1

1

I raised this in https://github.com/encode/httpx/discussions/2409

To silence the warning:

import warnings
from trio import TrioDeprecationWarning
warnings.filterwarnings(action='ignore', category=TrioDeprecationWarning)

As far as I understand, lastest Trio release is using some exception-handling machinery that's only just been added into Python in 3.11.0, which hasn't been released yet (it SHOULD have been, but release-date got pushed back). Presumably that's what has created this unusual situation, where a deprecation warning requires a Python-version that does not yet exist.

P i
  • 29,020
  • 36
  • 159
  • 267
  • 4
    It's not that 3.11 hasn't been released – there's a backport to use the new 3.11 feature on old versions. The issue is that the new standard feature replaces Trio's old hacky thing we used before Python had a proper solution, so now that we're migrating to use the proper thing (`ExceptionGroup`), we want to warn folks who are still using the old hacky thing (`MultiError`). In this case, it's `anyio` who's using `MultiError`, and it'll be fixed in the next anyio release. – Nathaniel J. Smith Oct 16 '22 at 09:21