Avoid off-by-one error in with-item named expressions (#8915)

## Summary

Given `with (a := b): pass`, we truncate the `WithItem` range by one on
both sides such that the parentheses are part of the statement, rather
than the item. However, for `with (a := b) as x: pass`, we want to avoid
this trick.

Closes https://github.com/astral-sh/ruff/issues/8913.
This commit is contained in:
Charlie Marsh
2023-11-29 16:11:04 -08:00
committed by GitHub
parent fd70cd789f
commit 774c77adae
4 changed files with 5 additions and 5 deletions

View File

@@ -347,7 +347,7 @@ expression: "parse_suite(source, \"<test>\").unwrap()"
is_async: false,
items: [
WithItem {
range: 184..195,
range: 183..196,
context_expr: NamedExpr(
ExprNamedExpr {
range: 184..190,

View File

@@ -782,7 +782,7 @@ expression: "parse_suite(source, \"<test>\").unwrap()"
is_async: false,
items: [
WithItem {
range: 382..393,
range: 381..394,
context_expr: NamedExpr(
ExprNamedExpr {
range: 382..388,