mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## Summary Ensures that we parenthesize expressions (if necessary) to preserve operator precedence in `FURB110`. Closes https://github.com/astral-sh/ruff/issues/11398.
49 lines
509 B
Python
49 lines
509 B
Python
z = x if x else y # FURB110
|
|
|
|
z = x \
|
|
if x else y # FURB110
|
|
|
|
z = x if x \
|
|
else \
|
|
y # FURB110
|
|
|
|
z = x() if x() else y() # FURB110
|
|
|
|
# FURB110
|
|
z = x if (
|
|
# Test for x.
|
|
x
|
|
) else (
|
|
# Test for y.
|
|
y
|
|
)
|
|
|
|
# FURB110
|
|
z = (
|
|
x if (
|
|
# Test for x.
|
|
x
|
|
) else (
|
|
# Test for y.
|
|
y
|
|
)
|
|
)
|
|
|
|
# FURB110
|
|
z = (
|
|
x if
|
|
# If true, use x.
|
|
x
|
|
# Otherwise, use y.
|
|
else
|
|
y
|
|
)
|
|
|
|
# FURB110
|
|
z = (
|
|
x
|
|
if x
|
|
else y
|
|
if y > 0
|
|
else None
|
|
)
|