python-trio / flake8-async

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

Suggest `sleep_forever()` if `trio.sleep()` is passed a >24hr interval #71

Closed Zac-HD closed 1 year ago

Zac-HD commented 1 year ago
# These examples are probably not meant to ever wake up:
await trio.sleep(100000)
await trio.sleep(10**10)

# and these ones _definitely_ never wake up:
await trio.sleep(float("inf"))
await trio.sleep(math.inf)
await trio.sleep(1e999)  # 'inf literal' overflow trick

This is a pretty simple check, but using await trio.sleep_forever() instead does have a certain elegance - and the first example (real code) might actually wake up if you leave the process running for ~27 hours!