Skip to content

almost identical await statement outside of a function and await outside of an asynchronous function errors #2598

@samuelcolvin

Description

@samuelcolvin

Summary

Running uvx ty example.py on

async def foo():
    return 123


await foo()

Emits:

error[invalid-syntax]: `await` statement outside of a function
 --> example.py:5:1
  |
5 | await foo()
  | ^^^^^^^^^^^
  |

error[invalid-syntax]: `await` outside of an asynchronous function
 --> example.py:5:1
  |
5 | await foo()
  | ^^^^^^^^^^^
  |

Found 2 diagnostics

Version

ty 0.0.13 (fc1478b 2026-01-21)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions