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

Allow user-configured decorator names to disable ASYNC900 #277

Closed
Zac-HD opened this issue Jul 31, 2024 · 0 comments · Fixed by #279
Closed

Allow user-configured decorator names to disable ASYNC900 #277

Zac-HD opened this issue Jul 31, 2024 · 0 comments · Fixed by #279

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Jul 31, 2024

Currently, we recognize that decorators named @asynccontextmanager and @fixture (including attributes and calls, so e.g. @pytest.fixture(...) also works) mean the function isn't really an async generator:

if isinstance(node, ast.AsyncFunctionDef) and not has_decorator(
node, "asynccontextmanager", "fixture"
):
self.unsafe_function = node

I think we should make this list extensible, similar to our existing no-checkpoint-warning-decorators list config. Could be called something like not-a-generator-decorators.

The motivation is that you might well want to use the nice syntax of yield, which is safe if wrapped in something like groove-x/trio-util#9 (see python-trio/trio#638 for design discussion). I'm inclined to see if we can upstream something similar into Trio and AnyIO, but even then there will be people on older versions of the libraries (or asyncio!) for years to come and so even if we add to the baseline list later having a config option seems useful.

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 a pull request may close this issue.

1 participant