[ty] Avoid duplicate syntax errors for await outside functions by ntBre · Pull Request #22826 · astral-sh/ruff (original) (raw)

@ntBre

Summary

This PR fixes astral-sh/ty#2598 by not emitting the YieldOutsideFunction syntax error for await expressions outside of functions. This isn't the most elegant fix, but as I noted in the TODO comment, I think a better long-term fix like not emitting YieldOutsideFunction errors for await at all would change the behavior of Ruff's stable F704 lint rule. We should be able to fix that and this TODO when resolving #19122.

Test Plan

We already had an existing mdtest for this behavior, so I just had to update it to remove the less specific error message

@ntBre ntBre added the ty

Multi-file analysis & type inference

label

Jan 23, 2026

AlexWaygood

@ntBre ntBre deleted the brent/duplicate-async-errors branch

January 23, 2026 21:05

carljm added a commit that referenced this pull request

Jan 30, 2026

@carljm

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})