---
source: crates/ruff_linter/src/rules/flynt/mod.rs
---
FLY002.py:5:7: FLY002 [*] Consider `f"{a}  World"` instead of string join
  |
4 | a = "Hello"
5 | ok1 = " ".join([a, " World"])  # OK
  |       ^^^^^^^^^^^^^^^^^^^^^^^ FLY002
6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
7 | ok3 = "x".join(("1", "2", "3"))  # OK
  |
  = help: Replace with `f"{a}  World"`

ℹ Unsafe fix
2 2 | from random import random, choice
3 3 | 
4 4 | a = "Hello"
5   |-ok1 = " ".join([a, " World"])  # OK
  5 |+ok1 = f"{a}  World"  # OK
6 6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
7 7 | ok3 = "x".join(("1", "2", "3"))  # OK
8 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally

FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join
  |
4 | a = "Hello"
5 | ok1 = " ".join([a, " World"])  # OK
6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002
7 | ok3 = "x".join(("1", "2", "3"))  # OK
8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
  |
  = help: Replace with `f"Finally, {a} World"`

ℹ Unsafe fix
3 3 | 
4 4 | a = "Hello"
5 5 | ok1 = " ".join([a, " World"])  # OK
6   |-ok2 = "".join(["Finally, ", a, " World"])  # OK
  6 |+ok2 = f"Finally, {a} World"  # OK
7 7 | ok3 = "x".join(("1", "2", "3"))  # OK
8 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
9 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)

FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join
  |
5 | ok1 = " ".join([a, " World"])  # OK
6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
7 | ok3 = "x".join(("1", "2", "3"))  # OK
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002
8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
  |
  = help: Replace with `"1x2x3"`

ℹ Unsafe fix
4 4 | a = "Hello"
5 5 | ok1 = " ".join([a, " World"])  # OK
6 6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
7   |-ok3 = "x".join(("1", "2", "3"))  # OK
  7 |+ok3 = "1x2x3"  # OK
8 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
9 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)

FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join
   |
 6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
 7 | ok3 = "x".join(("1", "2", "3"))  # OK
 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
   |       ^^^^^^^^^^^^^^^^^^^ FLY002
 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
   |
   = help: Replace with `f"{1}y{2}y{3}"`

ℹ Unsafe fix
5 5 | ok1 = " ".join([a, " World"])  # OK
6 6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
7 7 | ok3 = "x".join(("1", "2", "3"))  # OK
8   |-ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
  8 |+ok4 = f"{1}y{2}y{3}"  # Technically OK, though would've been an error originally
9 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
11 11 | 

FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join
   |
 7 | ok3 = "x".join(("1", "2", "3"))  # OK
 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002
10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
   |
   = help: Replace with `f"{random()}a{random()}"`

ℹ Unsafe fix
6  6  | ok2 = "".join(["Finally, ", a, " World"])  # OK
7  7  | ok3 = "x".join(("1", "2", "3"))  # OK
8  8  | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
9     |-ok5 = "a".join([random(), random()])  # OK (simple calls)
   9  |+ok5 = f"{random()}a{random()}"  # OK (simple calls)
10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
11 11 | 
12 12 | nok1 = "x".join({"4", "5", "yee"})  # Not OK (set)

FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join
   |
 8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
 9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002
11 | 
12 | nok1 = "x".join({"4", "5", "yee"})  # Not OK (set)
   |
   = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"`

ℹ Unsafe fix
7  7  | ok3 = "x".join(("1", "2", "3"))  # OK
8  8  | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
9  9  | ok5 = "a".join([random(), random()])  # OK (simple calls)
10    |-ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
   10 |+ok6 = f"{secrets.token_urlsafe()}a{secrets.token_hex()}"  # OK (attr calls)
11 11 | 
12 12 | nok1 = "x".join({"4", "5", "yee"})  # Not OK (set)
13 13 | nok2 = a.join(["1", "2", "3"])  # Not OK (not a static joiner)

FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join
   |
21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197
22 | def create_file_public_url(url, filename):
23 |     return''.join([url, filename])
   |           ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002
   |
   = help: Replace with `f"{url}{filename}"`

ℹ Unsafe fix
20 20 | 
21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197
22 22 | def create_file_public_url(url, filename):
23    |-    return''.join([url, filename])
   23 |+    return f"{url}{filename}"


