mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-22 20:45:11 +00:00
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:
parent
53246b725e
commit
e91caea490
3 changed files with 20 additions and 0 deletions
|
@ -371,3 +371,8 @@ def f( # first
|
||||||
# third
|
# third
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
# Walrus operator in return type.
|
||||||
|
def this_is_unusual() -> (please := no): ...
|
||||||
|
|
||||||
|
def this_is_unusual(x) -> (please := no): ...
|
||||||
|
|
|
@ -49,6 +49,7 @@ impl NeedsParentheses for ExprNamedExpr {
|
||||||
|| parent.is_expr_await()
|
|| parent.is_expr_await()
|
||||||
|| parent.is_stmt_delete()
|
|| parent.is_stmt_delete()
|
||||||
|| parent.is_stmt_for()
|
|| parent.is_stmt_for()
|
||||||
|
|| parent.is_stmt_function_def()
|
||||||
{
|
{
|
||||||
OptionalParentheses::Always
|
OptionalParentheses::Always
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -377,6 +377,11 @@ def f( # first
|
||||||
# third
|
# third
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
# Walrus operator in return type.
|
||||||
|
def this_is_unusual() -> (please := no): ...
|
||||||
|
|
||||||
|
def this_is_unusual(x) -> (please := no): ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Output
|
## Output
|
||||||
|
@ -905,6 +910,15 @@ def f( # first
|
||||||
/, # second
|
/, # second
|
||||||
):
|
):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# Walrus operator in return type.
|
||||||
|
def this_is_unusual() -> (please := no):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
def this_is_unusual(x) -> (please := no):
|
||||||
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue