Skip to content

Extend ASYNC401 to additional exception group assertions - #476

Open
anshurajbisoyi98-ctrl wants to merge 4 commits into
python-trio:mainfrom
anshurajbisoyi98-ctrl:fix-475-exception-group-checks
Open

anshurajbisoyi98-ctrl wants to merge 4 commits into
python-trio:mainfrom
anshurajbisoyi98-ctrl:fix-475-exception-group-checks

Conversation

@anshurajbisoyi98-ctrl

@anshurajbisoyi98-ctrl anshurajbisoyi98-ctrl commented Oct 2, 2026 •

Copy link
Copy Markdown

Fixes #475. ASYNC401 now catches more exception group assertions. I added regression tests. The ASYNC401 tests pass.

Comment thread docs/rules.rst Outdated

_`ASYNC401` : pytest-raises-exception-group
``pytest.raises(ExceptionGroup)`` and ``pytest.raises(BaseExceptionGroup)`` usually hide the structure of exception groups. Prefer ``pytest.RaisesGroup``.
Bare ``ExceptionGroup`` or ``BaseExceptionGroup`` expectations hide the structure of exception groups. Prefer ``pytest.RaisesGroup`` with explicit expectations for the contained exceptions. This checks ``pytest.raises``, ``pytest.RaisesExc``, ``pytest.RaisesGroup``, and the ``raises`` argument of ``pytest.mark.xfail``, including parameterized exception-group types.

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.

this might be more technically correct but is much harder to parse for a casual reader. "Bare ExceptionGroup expectations" is a mouthful and doesn't make me think of 'pytest.raises' until it's listed in the third sentence.
The description also does not need to fully list every single technical case that could trigger it, it's meant to give an easy overview of what the rule is for. Very common LLM:ism in my experience

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Shortened the docs entry back to the original wording and tweaked the message.

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.

Extend ASYNC401 to other forms

2 participants