Skip to content

iscoroutinefunction should use TypeIs #15529

@Redoubts

Description

@Redoubts

One of the things I find myself writing a lot is

if iscoroutinefunction(myfunction):
    do_something_with_async(myfunction)
else:
    do_something_with_just_sync(myfunction)

however the else block doesn't narrow the type to non-awaitable. Shouldn't it? Some of the other is... functions in inspect seem to use TypeIs as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: improvementImprove/refactor existing annotations, other stubs issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions