Skip to content

Add truthy-coroutine check #16069

Open
Open
@ikonst

Description

@ikonst

Feature

async def func() -> bool:
    return True

async def func2() -> None:
    if func():
        print("hi")

In this code, a likely fix is to change func() to await func(). Meanwhile, it'll always be true since a Coroutine is always true. The truthy-bool check could flag it but it's not enabled by default. We can add a new truthy-coroutine check (like truthy-function) for the specific case of using a Coroutine in boolean context.

The error message can suggest that an await might've been mistakenly omitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions