Fix miscellaneous issues in await-outside-async detection (#14218)

## Summary

Closes https://github.com/astral-sh/ruff/issues/14167.
This commit is contained in:
Charlie Marsh 2024-11-08 21:07:13 -05:00 committed by GitHub
parent b19f388249
commit 93fdf7ed36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 177 additions and 31 deletions

View file

@ -170,13 +170,21 @@ bitflags! {
pub enum ScopeKind<'a> {
Class(&'a ast::StmtClassDef),
Function(&'a ast::StmtFunctionDef),
Generator,
Generator(GeneratorKind),
Module,
/// A Python 3.12+ [annotation scope](https://docs.python.org/3/reference/executionmodel.html#annotation-scopes)
Type,
Lambda(&'a ast::ExprLambda),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GeneratorKind {
Generator,
ListComprehension,
DictComprehension,
SetComprehension,
}
/// Id uniquely identifying a scope in a program.
///
/// Using a `u32` is sufficient because Ruff only supports parsing documents with a size of max `u32::max`