python-trio / flake8-async

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

New rule: builtin `input()` should not be called from async function #199

Closed Zac-HD closed 4 months ago

Zac-HD commented 8 months ago
async def fn():
    ans = input("what to say")  # bad - no task can run while waiting for the user
    ans = await trio.to_thread.run_sync(input, "what to say")  # good, if inelegant

We could add this to TRIO222, or give it a new error code specific to this function.

jakkdl commented 8 months ago

I'll re-bump adding pre-commit.ci, will probably need to do a minor pass on any new changes in testing tools etc so I don't have to lump those into a feature PR.

jakkdl commented 4 months ago

note that this could be achieved with use of ASYNC200 and async200-blocking-calls, but agree it makes sense as a default rule. It doesn't quite fit with any 2xx rules, so I'm creating a new one for it.