Add test case for walrus operators in return types (#6438)

## Summary

Closes https://github.com/astral-sh/ruff/issues/6437.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-08-11 14:28:48 -04:00 committed by GitHub
parent 53246b725e
commit e91caea490
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -371,3 +371,8 @@ def f( # first
# third
):
...
# Walrus operator in return type.
def this_is_unusual() -> (please := no): ...
def this_is_unusual(x) -> (please := no): ...

View file

@ -49,6 +49,7 @@ impl NeedsParentheses for ExprNamedExpr {
|| parent.is_expr_await()
|| parent.is_stmt_delete()
|| parent.is_stmt_for()
|| parent.is_stmt_function_def()
{
OptionalParentheses::Always
} else {

View file

@ -377,6 +377,11 @@ def f( # first
# third
):
...
# Walrus operator in return type.
def this_is_unusual() -> (please := no): ...
def this_is_unusual(x) -> (please := no): ...
```
## Output
@ -905,6 +910,15 @@ def f( # first
/, # second
):
...
# Walrus operator in return type.
def this_is_unusual() -> (please := no):
...
def this_is_unusual(x) -> (please := no):
...
```