The Wayback Machine - https://web.archive.org/web/20221230013155/https://github.com/encode/starlette/pull/1932
Skip to content
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

Ignore Trio excepthook warning #1932

Merged
merged 2 commits into from Nov 2, 2022

Conversation

pquentin
Copy link
Contributor

@pquentin pquentin commented Nov 2, 2022

pytest 7.2.0 introduced the exceptiongroup backport as a dependency for Python < 3.11, which uses sys.excepthook to format ExceptionGroup exceptions.

But Trio 0.21.0 also uses sys.excepthook to format MultiError exceptions (the ancestor of ExceptionGroup). However, since there can only be one exception hook, Trio aborts when it finds the one set by the exceptiongroup backport and raises a warning.

There are three ways to fix this.

  1. Upgrade to Trio 0.22.0 which also uses the exceptiongroup backport. But AnyIO does not support Trio 0.22.0 just yet.
  2. Import trio before pytest in test_testclient.py, since exceptiongroup does not warn when an exceptiongroup exists. However, messing with isort --top option sounds confusing.
  3. Ignore this warning. Starlette does not use MultiError so it's harmless. This is what this commit does.

This was discussed here: https://gitter.im/python-trio/general?at=63617d79bad3c737520305af

Closes #1926

dependabot bot and others added 2 commits Nov 1, 2022
Bumps [pytest](https://github.com/pytest-dev/pytest) from 7.1.3 to 7.2.0.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](pytest-dev/pytest@7.1.3...7.2.0)

---
updated-dependencies:
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
pytest 7.2.0 introduced the exceptiongroup backport as a dependency for
Python < 3.11, which uses sys.excepthook to format ExceptionGroup
exceptions.

But Trio 0.21.0 also uses sys.excepthook to format MultiError exceptions
(the ancestor of ExceptionGroup). However, since there can only be one
exception hook, Trio aborts when it finds the one set by the
exceptiongroup backport and raises a warning.

There are three ways to fix this.

 1. Upgrade to Trio 0.22.0 which also uses the exceptiongroup backport.
    But AnyIO does not support Trio 0.22.0 just yet.
 2. Import `trio` before `pytest` in test_testclient.py, since
    exceptiongroup does not warn when an exceptiongroup exists. However,
    messing with isort `--top` option sounds confusing.
 3. Ignore this warning. Starlette does not use MultiError so it's
    harmless. This is what this commit does.
@pquentin pquentin changed the base branch from dependabot/pip/pytest-7.2.0 to master Nov 2, 2022
@Kludex
Copy link
Sponsor Member

Kludex commented Nov 2, 2022

Oh! You did it for me! 🥺 ❤️

Thank you! 🙌

Kludex
Kludex approved these changes Nov 2, 2022
@Kludex
Copy link
Sponsor Member

Kludex commented Nov 2, 2022

Pipeline went on vacation... 🤔

@iudeen
Copy link

iudeen commented Nov 2, 2022

Happened to me several times. I had to close and reopen the PR.

@pquentin pquentin closed this Nov 2, 2022
@pquentin pquentin reopened this Nov 2, 2022
@Kludex
Copy link
Sponsor Member

Kludex commented Nov 2, 2022

Magic! 🪄

@Kludex Kludex merged commit fbab16a into encode:master Nov 2, 2022
5 checks passed
@pquentin pquentin deleted the dependabot/pip/pytest-7.2.0 branch Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants