|
| 1 | +--- |
| 2 | +source: crates/ruff/src/rules/flynt/mod.rs |
| 3 | +--- |
| 4 | +FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join |
| 5 | + | |
| 6 | +5 | a = "Hello" |
| 7 | +6 | ok1 = " ".join([a, " World"]) # OK |
| 8 | + | ^^^^^^^^^^^^^^^^^^^^^^^ FLY002 |
| 9 | +7 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 10 | +8 | ok3 = "x".join(("1", "2", "3")) # OK |
| 11 | + | |
| 12 | + = help: Replace with `f"{a} World"` |
| 13 | + |
| 14 | +ℹ Suggested fix |
| 15 | +2 2 | from random import random, choice |
| 16 | +3 3 | |
| 17 | +4 4 | a = "Hello" |
| 18 | +5 |-ok1 = " ".join([a, " World"]) # OK |
| 19 | + 5 |+ok1 = f"{a} World" # OK |
| 20 | +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 21 | +7 7 | ok3 = "x".join(("1", "2", "3")) # OK |
| 22 | +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 23 | + |
| 24 | +FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join |
| 25 | + | |
| 26 | + 6 | a = "Hello" |
| 27 | + 7 | ok1 = " ".join([a, " World"]) # OK |
| 28 | + 8 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 29 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 |
| 30 | + 9 | ok3 = "x".join(("1", "2", "3")) # OK |
| 31 | +10 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 32 | + | |
| 33 | + = help: Replace with `f"Finally, {a} World"` |
| 34 | + |
| 35 | +ℹ Suggested fix |
| 36 | +3 3 | |
| 37 | +4 4 | a = "Hello" |
| 38 | +5 5 | ok1 = " ".join([a, " World"]) # OK |
| 39 | +6 |-ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 40 | + 6 |+ok2 = f"Finally, {a} World" # OK |
| 41 | +7 7 | ok3 = "x".join(("1", "2", "3")) # OK |
| 42 | +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 43 | +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 44 | + |
| 45 | +FLY002.py:7:7: FLY002 [*] Consider `f"1x2x3"` instead of string join |
| 46 | + | |
| 47 | + 7 | ok1 = " ".join([a, " World"]) # OK |
| 48 | + 8 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 49 | + 9 | ok3 = "x".join(("1", "2", "3")) # OK |
| 50 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 |
| 51 | +10 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 52 | +11 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 53 | + | |
| 54 | + = help: Replace with `f"1x2x3"` |
| 55 | + |
| 56 | +ℹ Suggested fix |
| 57 | +4 4 | a = "Hello" |
| 58 | +5 5 | ok1 = " ".join([a, " World"]) # OK |
| 59 | +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 60 | +7 |-ok3 = "x".join(("1", "2", "3")) # OK |
| 61 | + 7 |+ok3 = f"1x2x3" # OK |
| 62 | +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 63 | +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 64 | +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 65 | + |
| 66 | +FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join |
| 67 | + | |
| 68 | + 8 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 69 | + 9 | ok3 = "x".join(("1", "2", "3")) # OK |
| 70 | +10 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 71 | + | ^^^^^^^^^^^^^^^^^^^ FLY002 |
| 72 | +11 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 73 | +12 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 74 | + | |
| 75 | + = help: Replace with `f"{1}y{2}y{3}"` |
| 76 | + |
| 77 | +ℹ Suggested fix |
| 78 | +5 5 | ok1 = " ".join([a, " World"]) # OK |
| 79 | +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 80 | +7 7 | ok3 = "x".join(("1", "2", "3")) # OK |
| 81 | +8 |-ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 82 | + 8 |+ok4 = f"{1}y{2}y{3}" # Technically OK, though would've been an error originally |
| 83 | +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 84 | +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 85 | +11 11 | |
| 86 | + |
| 87 | +FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join |
| 88 | + | |
| 89 | + 9 | ok3 = "x".join(("1", "2", "3")) # OK |
| 90 | +10 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 91 | +11 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 92 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 |
| 93 | +12 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 94 | + | |
| 95 | + = help: Replace with `f"{random()}a{random()}"` |
| 96 | + |
| 97 | +ℹ Suggested fix |
| 98 | +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK |
| 99 | +7 7 | ok3 = "x".join(("1", "2", "3")) # OK |
| 100 | +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 101 | +9 |-ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 102 | + 9 |+ok5 = f"{random()}a{random()}" # OK (simple calls) |
| 103 | +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 104 | +11 11 | |
| 105 | +12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) |
| 106 | + |
| 107 | +FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join |
| 108 | + | |
| 109 | +10 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 110 | +11 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 111 | +12 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 112 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 |
| 113 | +13 | |
| 114 | +14 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) |
| 115 | + | |
| 116 | + = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` |
| 117 | + |
| 118 | +ℹ Suggested fix |
| 119 | +7 7 | ok3 = "x".join(("1", "2", "3")) # OK |
| 120 | +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally |
| 121 | +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) |
| 122 | +10 |-ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) |
| 123 | + 10 |+ok6 = f"{secrets.token_urlsafe()}a{secrets.token_hex()}" # OK (attr calls) |
| 124 | +11 11 | |
| 125 | +12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) |
| 126 | +13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) |
| 127 | + |
| 128 | + |
0 commit comments