ruff/crates/ruff_linter/resources/test/fixtures/refurb/FURB110.py
Charlie Marsh 48b0660228
Respect operator precedence in FURB110 (#11464)
## Summary

Ensures that we parenthesize expressions (if necessary) to preserve
operator precedence in `FURB110`.

Closes https://github.com/astral-sh/ruff/issues/11398.
2024-05-19 03:17:11 +00:00

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
)