Skip to content

unused-coroutine could catch a common bug #5151

Description

@eteran

Describe the Bug

More of a feature request than a bug, but there's a common bug pattern that could be caught, likely should go under the unused-coroutine check. Basically this:

async def foo() -> bool: ...

async def bar():
    if foo():
        print("always evaluates to True! foo should have been awaited")

This does get caught as a runtime error when things get GC'd, and does technically get caught by the implicit-bool checker, but I think that general implicit conversions to bool are pretty common. But implicitly converting a coroutine to bool seems like almost universally an error.

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pZXPboMwDMZfxS0HLtty722XSZN62ANwCRAgGsUTSYr29vtsYKP7U03qDQj-nPj72flrZH5v5a21DfPsbIkGXss0w_Jkgcg_QIDdqnKgTAZK7ytwUfGw1o4bvI2cogfykTXTHU2c-hot_arfKhurjmIH4CePyqdInT3LjMciGCl9TY_H42_68H2FeKGm2Nt-su_wXni3qJ6oCD472SkF6CM3EjgqnQMmgrKri70i-ROGjF7mD7TUVdI3vk0YttjBQzFkmLOOuhjfwsGYNZzH1rjB1FwFcxFh5Exkz9brCL-UI1Z4A2RvoTCfIcyvMZgLgvhDDvCcL3bI1tSJT1983EmaFBD_ZeUWYRHQGA2QmwXXWgkXm962gbB3rA54ip0FiaOYDnU-nbAkCZOmc4OWw0fRW72-F2A22a72wAc

(Only applicable for extension issues) IDE Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions