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

FLY002 [*] Consider `f"Finally, {a} World"` instead of string join
 --> FLY002.py:6:7
  |
4 | a = "Hello"
5 | ok1 = " ".join([a, " World"])  # OK
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
  |
help: Replace with `f"Finally, {a} World"`
  |
5 | ok1 = " ".join([a, " World"])  # OK
  - ok2 = "".join(["Finally, ", a, " World"])  # OK
6 + ok2 = f"Finally, {a} World"  # OK
7 | ok3 = "x".join(("1", "2", "3"))  # OK
  |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `"1x2x3"` instead of string join
 --> FLY002.py:7:7
  |
5 | ok1 = " ".join([a, " World"])  # OK
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
9 | ok5 = "a".join([random(), random()])  # OK (simple calls)
  |
help: Replace with `"1x2x3"`
  |
6 | ok2 = "".join(["Finally, ", a, " World"])  # OK
  - ok3 = "x".join(("1", "2", "3"))  # OK
7 + ok3 = "1x2x3"  # OK
8 | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
  |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join
  --> FLY002.py:8:7
   |
 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
   |       ^^^^^^^^^^^^^^^^^^^
 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}"`
  |
7 | ok3 = "x".join(("1", "2", "3"))  # OK
  - 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 | ok5 = "a".join([random(), random()])  # OK (simple calls)
  |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join
  --> FLY002.py:9: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
 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"{random()}a{random()}"`
   |
8  | ok4 = "y".join([1, 2, 3])  # Technically OK, though would've been an error originally
   - ok5 = "a".join([random(), random()])  # OK (simple calls)
9  + ok5 = f"{random()}a{random()}"  # OK (simple calls)
10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()])  # OK (attr calls)
   |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join
  --> FLY002.py:10:7
   |
 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)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 |
12 | nok1 = "x".join({"4", "5", "yee"})  # Not OK (set)
   |
help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"`
   |
9  | ok5 = "a".join([random(), random()])  # OK (simple calls)
   - 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 |
   |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider f-string instead of string join
  --> FLY002.py:20:8
   |
18 | nok7 = "a".join([f"foo{8}", "bar"])  # Not OK (contains an f-string)
19 | # https://github.com/astral-sh/ruff/issues/19887
20 | nok8 = '\n'.join([r'line1','line2'])
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21 | nok9 = '\n'.join([r"raw string", '<""">', "<'''>"])  # Not OK (both triple-quote delimiters appear; should bail)
   |
help: Replace with f-string
   |
19 | # https://github.com/astral-sh/ruff/issues/19887
   - nok8 = '\n'.join([r'line1','line2'])
20 + nok8 = r'''line1
21 + line2'''
22 | nok9 = '\n'.join([r"raw string", '<""">', "<'''>"])  # Not OK (both triple-quote delimiters appear; should bail)
   |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f"{url}{filename}"` instead of string join
  --> FLY002.py:25:11
   |
23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197
24 | def create_file_public_url(url, filename):
25 |     return''.join([url, filename])
   |           ^^^^^^^^^^^^^^^^^^^^^^^^
26 |
27 | # Regression test for: https://github.com/astral-sh/ruff/issues/19837
   |
help: Replace with `f"{url}{filename}"`
   |
24 | def create_file_public_url(url, filename):
   -     return''.join([url, filename])
25 +     return f"{url}{filename}"
26 |
   |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f'{foo}"'` instead of string join
  --> FLY002.py:28:9
   |
27 | # Regression test for: https://github.com/astral-sh/ruff/issues/19837
28 | nok10 = "".join((foo, '"'))
   |         ^^^^^^^^^^^^^^^^^^^
29 | nok11 = ''.join((foo, "'"))
30 | nok12 = ''.join([foo, "'", '"'])
   |
help: Replace with `f'{foo}"'`
   |
27 | # Regression test for: https://github.com/astral-sh/ruff/issues/19837
   - nok10 = "".join((foo, '"'))
28 + nok10 = f'{foo}"'
29 | nok11 = ''.join((foo, "'"))
   |
note: This is an unsafe fix and may change runtime behavior

FLY002 [*] Consider `f"{foo}'"` instead of string join
  --> FLY002.py:29:9
   |
27 | # Regression test for: https://github.com/astral-sh/ruff/issues/19837
28 | nok10 = "".join((foo, '"'))
29 | nok11 = ''.join((foo, "'"))
   |         ^^^^^^^^^^^^^^^^^^^
30 | nok12 = ''.join([foo, "'", '"'])
31 | nok13 = "".join([foo, "'", '"'])
   |
help: Replace with `f"{foo}'"`
   |
28 | nok10 = "".join((foo, '"'))
   - nok11 = ''.join((foo, "'"))
29 + nok11 = f"{foo}'"
30 | nok12 = ''.join([foo, "'", '"'])
   |
note: This is an unsafe fix and may change runtime behavior
