Skip to content

Not-awaitable diagnostic context skips some steps #3250

@carljm

Description

@carljm

For this code:

class NotAwaitable:
    __await__ = 1
    
async def _(na: NotAwaitable):
    await na

We emit this diagnostic:

error[invalid-await]: `NotAwaitable` is not awaitable
   --> main.py:5:11
    |
  4 | async def _(na: NotAwaitable):
  5 |     await na
    |           ^^
    |
   ::: stdlib/builtins.pyi:348:7
    |
347 | @disjoint_base
348 | class int:
    |       --- attribute defined here
349 |     """int([x]) -> integer
350 |     int(x, base=10) -> integer
    |
info: `__await__` is not callable

It's kind of strange/confusing that we jump straight to highlighting int in stdlib, when the more relevant thing to highlight would be __await__ = 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsRelated to reporting of diagnostics.help wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions