python-trio / flake8-async

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

add async120, await-in-except #265

Closed jakkdl closed 3 months ago

jakkdl commented 4 months ago

First part of #262

It's maybe not great to have the same error messages for both 102 and 120, and docs could maybe be improved as well.

jakkdl commented 4 months ago

I noticed the "exclude x.aclose()" just now, I don't remember the reasoning behind that, so idk if 120 should respect it as well.

jakkdl commented 4 months ago

I just reread https://github.com/python-trio/trio/issues/455#issuecomment-2136041817 and noticed

I guess we should add any other except-that-raises here.

and realized that this check does not filter on whether-the-except-would-otherwise-raise, so this will currently give an async120 error:

try:
  ...
except ValueError:
  # we don't give a shit about ValueError
  await doSomeOtherThing()

can fix it by saving the potential async120 errors in a container and only report them upon reaching a raise

Zac-HD commented 3 months ago

(I haven't forgotten this, I just need to think it through carefully and haven't had a block of time free to do that lately)