Skip to content

Add ASYNC401 for pytest.raises(ExceptionGroup)#466

Open
paranoa233 wants to merge 2 commits into
python-trio:mainfrom
paranoa233:fix-pytest-raises-exceptiongroup-430
Open

Add ASYNC401 for pytest.raises(ExceptionGroup)#466
paranoa233 wants to merge 2 commits into
python-trio:mainfrom
paranoa233:fix-pytest-raises-exceptiongroup-430

Conversation

@paranoa233

Copy link
Copy Markdown

Closes #430.

Summary

  • add opt-in ASYNC401 for pytest.raises(ExceptionGroup/BaseExceptionGroup)
  • detect direct, keyword, tuple, builtins-qualified, backport, and imported pytest.raises forms
  • document the new rule and add changelog coverage

Tests

  • python -m pytest tests/test_flake8_async.py -k ASYNC401
  • python -m pytest tests/test_messages_documented.py
  • python -m pytest tests/test_all_visitors_imported.py
  • python -m pytest --ignore=tests/test_config_and_args.py

@paranoa233 paranoa233 force-pushed the fix-pytest-raises-exceptiongroup-430 branch from 1c23490 to 4e4c1d1 Compare July 8, 2026 15:26
@jakkdl

jakkdl commented Jul 14, 2026

Copy link
Copy Markdown
Member

I'd lean towards default on

Comment thread flake8_async/visitors/visitor4xx.py Outdated


@error_class
@disabled_by_default

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that I'd prefer to have this enabled by default, otherwise looks ready to go - thanks @paranoa233!

Comment thread docs/changelog.rst Outdated

26.6.1
======
- Add :ref:`ASYNC401 <async401>` pytest-raises-exception-group, an opt-in rule recommending ``pytest.RaisesGroup`` over ``pytest.raises(ExceptionGroup)``. `(issue #430) <https://github.com/python-trio/flake8-async/issues/430>`_

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, and this will need to go under a new heading for 27.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint rule for pytest.raises(ExceptionGroup)

3 participants