Add comment test for FURB110 (#10804)

This commit is contained in:
Charlie Marsh 2024-04-06 12:49:22 -04:00 committed by GitHub
parent 7fb012d0df
commit ee4bff3475
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -28,3 +28,13 @@ z = (
y
)
)
# FURB110
z = (
x if
# If true, use x.
x
# Otherwise, use y.
else
y
)

View file

@ -148,3 +148,32 @@ FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator
27 27 | # Test for y.
28 28 | y
29 29 | )
FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator
|
32 | # FURB110
33 | z = (
34 | x if
| _____^
35 | | # If true, use x.
36 | | x
37 | | # Otherwise, use y.
38 | | else
39 | | y
| |_____^ FURB110
40 | )
|
= help: Replace with `or` operator
Safe fix
31 31 |
32 32 | # FURB110
33 33 | z = (
34 |- x if
35 |- # If true, use x.
36 |- x
37 |- # Otherwise, use y.
38 |- else
39 |- y
34 |+ x or y
40 35 | )