python-trio / flake8-async

Highly opinionated linter for Trio code
https://flake8-async.readthedocs.io
MIT License
17 stars 2 forks source link

Add asyncio support to current checks #208

Open jakkdl opened 7 months ago

jakkdl commented 7 months ago

Could also consider supporting curio or any other IO library.

Zac-HD commented 7 months ago

I don't think we should support other libraries - curio is no longer being updated, twisted is more callback than async, others are even smaller.

jakkdl commented 7 months ago

partial

todo

tracked in #215

jakkdl commented 4 months ago

[this comment previously talked about ASYNC111, but async support for 111 was already implemented at the time of posting :confused: ]

jakkdl commented 4 months ago

One part that leaves me somewhat confused about implementing ASYNC113 is what, if anything, to do about ASYNC114. Currently we gate ASYNC113 to only warn on startable methods, presumably to reduce false positives when you don't care about the background task being properly up and running. But I don't think there's any way to differentiate those for asyncio tasks, so we're left with the options of:

  1. Always warn on all calls
  2. Only warn for calls specified in startable_in_context_manager.

If startable_in_context_manager was expanded to support wildcards, we could get the best of both worlds by telling asyncio users to specify * if they want the former behaviour. (this would also allow anyio/trio users to go maximum defensiveness, in case they're starting functions not defined in code that could trigger ASYNC114, or they might've forgotten to add task_status to functions)

Another problem is that since there's no .start()-equivalent that guarantees that the task has been started, there's no standardized way of alleviating the problem that we could detect, so users are left to handle it in whatever way they can, and then noqa the warning.