---
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs
---
UP031 [*] Use format specifiers instead of percent format
 --> UP031_0.py:4:7
  |
3 | # UP031
4 | print('%s %s' % (a, b))
  |       ^^^^^^^^^^^^^^^^
5 |
6 | print('%s%s' % (a, b))
  |
help: Replace with format specifiers
  |
3 | # UP031
  - print('%s %s' % (a, b))
4 + print('{} {}'.format(a, b))
5 |
  |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
 --> UP031_0.py:6:7
  |
4 | print('%s %s' % (a, b))
5 |
6 | print('%s%s' % (a, b))
  |       ^^^^^^^^^^^^^^^
7 |
8 | print("trivial" % ())
  |
help: Replace with format specifiers
  |
5 |
  - print('%s%s' % (a, b))
6 + print('{}{}'.format(a, b))
7 |
  |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:8:7
   |
 6 | print('%s%s' % (a, b))
 7 |
 8 | print("trivial" % ())
   |       ^^^^^^^^^^^^^^
 9 |
10 | print("%s" % ("simple",))
   |
help: Replace with format specifiers
  |
7 |
  - print("trivial" % ())
8 + print("trivial".format())
9 |
  |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:10:7
   |
 8 | print("trivial" % ())
 9 |
10 | print("%s" % ("simple",))
   |       ^^^^^^^^^^^^^^^^^^
11 |
12 | print("%s" % ("%s" % ("nested",),))
   |
help: Replace with format specifiers
   |
9  |
   - print("%s" % ("simple",))
10 + print("{}".format("simple"))
11 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:12:7
   |
10 | print("%s" % ("simple",))
11 |
12 | print("%s" % ("%s" % ("nested",),))
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13 |
14 | print("%s%% percent" % (15,))
   |
help: Replace with format specifiers
   |
11 |
   - print("%s" % ("%s" % ("nested",),))
12 + print("{}".format("%s" % ("nested",)))
13 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:12:15
   |
10 | print("%s" % ("simple",))
11 |
12 | print("%s" % ("%s" % ("nested",),))
   |               ^^^^^^^^^^^^^^^^^^
13 |
14 | print("%s%% percent" % (15,))
   |
help: Replace with format specifiers
   |
11 |
   - print("%s" % ("%s" % ("nested",),))
12 + print("%s" % ("{}".format("nested"),))
13 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:14:7
   |
12 | print("%s" % ("%s" % ("nested",),))
13 |
14 | print("%s%% percent" % (15,))
   |       ^^^^^^^^^^^^^^^^^^^^^^
15 |
16 | print("%f" % (15,))
   |
help: Replace with format specifiers
   |
13 |
   - print("%s%% percent" % (15,))
14 + print("{}% percent".format(15))
15 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:16:7
   |
14 | print("%s%% percent" % (15,))
15 |
16 | print("%f" % (15,))
   |       ^^^^^^^^^^^^
17 |
18 | print("%.f" % (15,))
   |
help: Replace with format specifiers
   |
15 |
   - print("%f" % (15,))
16 + print("{:f}".format(15))
17 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:18:7
   |
16 | print("%f" % (15,))
17 |
18 | print("%.f" % (15,))
   |       ^^^^^^^^^^^^^
19 |
20 | print("%.3f" % (15,))
   |
help: Replace with format specifiers
   |
17 |
   - print("%.f" % (15,))
18 + print("{:.0f}".format(15))
19 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:20:7
   |
18 | print("%.f" % (15,))
19 |
20 | print("%.3f" % (15,))
   |       ^^^^^^^^^^^^^^
21 |
22 | print("%3f" % (15,))
   |
help: Replace with format specifiers
   |
19 |
   - print("%.3f" % (15,))
20 + print("{:.3f}".format(15))
21 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:22:7
   |
20 | print("%.3f" % (15,))
21 |
22 | print("%3f" % (15,))
   |       ^^^^^^^^^^^^^
23 |
24 | print("%-5f" % (5,))
   |
help: Replace with format specifiers
   |
21 |
   - print("%3f" % (15,))
22 + print("{:3f}".format(15))
23 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:24:7
   |
22 | print("%3f" % (15,))
23 |
24 | print("%-5f" % (5,))
   |       ^^^^^^^^^^^^^
25 |
26 | print("%9f" % (5,))
   |
help: Replace with format specifiers
   |
23 |
   - print("%-5f" % (5,))
24 + print("{:<5f}".format(5))
25 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:26:7
   |
24 | print("%-5f" % (5,))
25 |
26 | print("%9f" % (5,))
   |       ^^^^^^^^^^^^
27 |
28 | print("%#o" % (123,))
   |
help: Replace with format specifiers
   |
25 |
   - print("%9f" % (5,))
26 + print("{:9f}".format(5))
27 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:28:7
   |
26 | print("%9f" % (5,))
27 |
28 | print("%#o" % (123,))
   |       ^^^^^^^^^^^^^^
29 |
30 | print("brace {} %s" % (1,))
   |
help: Replace with format specifiers
   |
27 |
   - print("%#o" % (123,))
28 + print("{:#o}".format(123))
29 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:30:7
   |
28 | print("%#o" % (123,))
29 |
30 | print("brace {} %s" % (1,))
   |       ^^^^^^^^^^^^^^^^^^^^
31 |
32 | print((
   |
help: Replace with format specifiers
   |
29 |
   - print("brace {} %s" % (1,))
30 + print("brace {{}} {}".format(1))
31 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:33:5
   |
32 |   print((
33 | /     "foo %s "
34 | |     "bar %s" % (x, y)
   | |_____________________^
35 |   ))
   |
help: Replace with format specifiers
   |
32 | print((
   -     "foo %s "
   -     "bar %s" % (x, y)
33 +     "foo {} "
34 +     "bar {}".format(x, y)
35 | ))
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:38:3
   |
37 |   print(
38 | /   "%s" % (
39 | |     "trailing comma",
40 | |         )
   | |_________^
41 |   )
   |
help: Replace with format specifiers
   |
37 | print(
   -   "%s" % (
38 +   "{}".format(
39 |     "trailing comma",
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:43:7
   |
41 | )
42 |
43 | print("foo %s " % (x,))
   |       ^^^^^^^^^^^^^^^^
44 |
45 | print("%(k)s" % {"k": "v"})
   |
help: Replace with format specifiers
   |
42 |
   - print("foo %s " % (x,))
43 + print("foo {} ".format(x))
44 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:45:7
   |
43 | print("foo %s " % (x,))
44 |
45 | print("%(k)s" % {"k": "v"})
   |       ^^^^^^^^^^^^^^^^^^^^
46 |
47 | print("%(k)s" % {
   |
help: Replace with format specifiers
   |
44 |
   - print("%(k)s" % {"k": "v"})
45 + print("{k}".format(k="v"))
46 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:47:7
   |
45 |   print("%(k)s" % {"k": "v"})
46 |
47 |   print("%(k)s" % {
   |  _______^
48 | |     "k": "v",
49 | |     "i": "j"
50 | | })
   | |_^
51 |
52 |   print("%(to_list)s" % {"to_list": []})
   |
help: Replace with format specifiers
   |
46 |
   - print("%(k)s" % {
   -     "k": "v",
   -     "i": "j"
   - })
47 + print("{k}".format(
48 +     k="v",
49 +     i="j",
50 + ))
51 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:52:7
   |
50 | })
51 |
52 | print("%(to_list)s" % {"to_list": []})
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53 |
54 | print("%(k)s" % {"k": "v", "i": 1, "j": []})
   |
help: Replace with format specifiers
   |
51 |
   - print("%(to_list)s" % {"to_list": []})
52 + print("{to_list}".format(to_list=[]))
53 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:54:7
   |
52 | print("%(to_list)s" % {"to_list": []})
53 |
54 | print("%(k)s" % {"k": "v", "i": 1, "j": []})
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55 |
56 | print("%(ab)s" % {"a" "b": 1})
   |
help: Replace with format specifiers
   |
53 |
   - print("%(k)s" % {"k": "v", "i": 1, "j": []})
54 + print("{k}".format(k="v", i=1, j=[]))
55 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:56:7
   |
54 | print("%(k)s" % {"k": "v", "i": 1, "j": []})
55 |
56 | print("%(ab)s" % {"a" "b": 1})
   |       ^^^^^^^^^^^^^^^^^^^^^^^
57 |
58 | print("%(a)s" % {"a"  :  1})
   |
help: Replace with format specifiers
   |
55 |
   - print("%(ab)s" % {"a" "b": 1})
56 + print("{ab}".format(ab=1))
57 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:58:7
   |
56 | print("%(ab)s" % {"a" "b": 1})
57 |
58 | print("%(a)s" % {"a"  :  1})
   |       ^^^^^^^^^^^^^^^^^^^^^
   |
help: Replace with format specifiers
   |
57 |
   - print("%(a)s" % {"a"  :  1})
58 + print("{a}".format(a=1))
59 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:62:5
   |
61 |   print(
62 | /     "foo %(foo)s "
63 | |     "bar %(bar)s" % {"foo": x, "bar": y}
   | |________________________________________^
64 |   )
   |
help: Replace with format specifiers
   |
61 | print(
   -     "foo %(foo)s "
   -     "bar %(bar)s" % {"foo": x, "bar": y}
62 +     "foo {foo} "
63 +     "bar {bar}".format(foo=x, bar=y)
64 | )
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:68:5
   |
66 |   bar = {"bar": y}
67 |   print(
68 | /     "foo %(foo)s "
69 | |     "bar %(bar)s" % {"foo": x, **bar}
   | |_____________________________________^
70 |   )
   |
help: Replace with format specifiers
   |
67 | print(
   -     "foo %(foo)s "
   -     "bar %(bar)s" % {"foo": x, **bar}
68 +     "foo {foo} "
69 +     "bar {bar}".format(foo=x, **bar)
70 | )
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:72:7
   |
70 | )
71 |
72 | print("%s \N{snowman}" % (a,))
   |       ^^^^^^^^^^^^^^^^^^^^^^^
73 |
74 | print("%(foo)s \N{snowman}" % {"foo": 1})
   |
help: Replace with format specifiers
   |
71 |
   - print("%s \N{snowman}" % (a,))
72 + print("{} \N{snowman}".format(a))
73 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:74:7
   |
72 | print("%s \N{snowman}" % (a,))
73 |
74 | print("%(foo)s \N{snowman}" % {"foo": 1})
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75 |
76 | print(("foo %s " "bar %s") % (x, y))
   |
help: Replace with format specifiers
   |
73 |
   - print("%(foo)s \N{snowman}" % {"foo": 1})
74 + print("{foo} \N{snowman}".format(foo=1))
75 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:76:7
   |
74 | print("%(foo)s \N{snowman}" % {"foo": 1})
75 |
76 | print(("foo %s " "bar %s") % (x, y))
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77 |
78 | # Single-value expressions
   |
help: Replace with format specifiers
   |
75 |
   - print(("foo %s " "bar %s") % (x, y))
76 + print(("foo {} " "bar {}").format(x, y))
77 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:79:7
   |
78 | # Single-value expressions
79 | print('Hello %s' % "World")
   |       ^^^^^^^^^^^^^^^^^^^^
80 | print('Hello %s' % f"World")
81 | print('Hello %s (%s)' % bar)
   |
help: Replace with format specifiers
   |
78 | # Single-value expressions
   - print('Hello %s' % "World")
79 + print('Hello {}'.format("World"))
80 | print('Hello %s' % f"World")
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:80:7
   |
78 | # Single-value expressions
79 | print('Hello %s' % "World")
80 | print('Hello %s' % f"World")
   |       ^^^^^^^^^^^^^^^^^^^^^
81 | print('Hello %s (%s)' % bar)
82 | print('Hello %s (%s)' % bar.baz)
   |
help: Replace with format specifiers
   |
79 | print('Hello %s' % "World")
   - print('Hello %s' % f"World")
80 + print('Hello {}'.format(f"World"))
81 | print('Hello %s (%s)' % bar)
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:81:7
   |
79 | print('Hello %s' % "World")
80 | print('Hello %s' % f"World")
81 | print('Hello %s (%s)' % bar)
   |       ^^^^^^^^^^^^^^^^^^^^^
82 | print('Hello %s (%s)' % bar.baz)
83 | print('Hello %s (%s)' % bar['bop'])
   |
help: Replace with format specifiers
   |
80 | print('Hello %s' % f"World")
   - print('Hello %s (%s)' % bar)
81 + print('Hello {} ({})'.format(*bar))
82 | print('Hello %s (%s)' % bar.baz)
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:82:7
   |
80 | print('Hello %s' % f"World")
81 | print('Hello %s (%s)' % bar)
82 | print('Hello %s (%s)' % bar.baz)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^
83 | print('Hello %s (%s)' % bar['bop'])
84 | print('Hello %(arg)s' % bar)
   |
help: Replace with format specifiers
   |
81 | print('Hello %s (%s)' % bar)
   - print('Hello %s (%s)' % bar.baz)
82 + print('Hello {} ({})'.format(*bar.baz))
83 | print('Hello %s (%s)' % bar['bop'])
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:83:7
   |
81 | print('Hello %s (%s)' % bar)
82 | print('Hello %s (%s)' % bar.baz)
83 | print('Hello %s (%s)' % bar['bop'])
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84 | print('Hello %(arg)s' % bar)
85 | print('Hello %(arg)s' % bar.baz)
   |
help: Replace with format specifiers
   |
82 | print('Hello %s (%s)' % bar.baz)
   - print('Hello %s (%s)' % bar['bop'])
83 + print('Hello {} ({})'.format(*bar['bop']))
84 | print('Hello %(arg)s' % bar)
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:84:7
   |
82 | print('Hello %s (%s)' % bar.baz)
83 | print('Hello %s (%s)' % bar['bop'])
84 | print('Hello %(arg)s' % bar)
   |       ^^^^^^^^^^^^^^^^^^^^^
85 | print('Hello %(arg)s' % bar.baz)
86 | print('Hello %(arg)s' % bar['bop'])
   |
help: Replace with format specifiers
   |
83 | print('Hello %s (%s)' % bar['bop'])
   - print('Hello %(arg)s' % bar)
84 + print('Hello {arg}'.format(**bar))
85 | print('Hello %(arg)s' % bar.baz)
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:85:7
   |
83 | print('Hello %s (%s)' % bar['bop'])
84 | print('Hello %(arg)s' % bar)
85 | print('Hello %(arg)s' % bar.baz)
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^
86 | print('Hello %(arg)s' % bar['bop'])
   |
help: Replace with format specifiers
   |
84 | print('Hello %(arg)s' % bar)
   - print('Hello %(arg)s' % bar.baz)
85 + print('Hello {arg}'.format(**bar.baz))
86 | print('Hello %(arg)s' % bar['bop'])
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:86:7
   |
84 | print('Hello %(arg)s' % bar)
85 | print('Hello %(arg)s' % bar.baz)
86 | print('Hello %(arg)s' % bar['bop'])
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87 |
88 | # Hanging modulos
   |
help: Replace with format specifiers
   |
85 | print('Hello %(arg)s' % bar.baz)
   - print('Hello %(arg)s' % bar['bop'])
86 + print('Hello {arg}'.format(**bar['bop']))
87 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:89:1
   |
88 |   # Hanging modulos
89 | / (
90 | |     "foo %s "
91 | |     "bar %s"
92 | | ) % (x, y)
   | |__________^
93 |
94 |   (
   |
help: Replace with format specifiers
   |
89 | (
   -     "foo %s "
   -     "bar %s"
   - ) % (x, y)
90 +     "foo {} "
91 +     "bar {}"
92 + ).format(x, y)
93 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
  --> UP031_0.py:94:1
   |
92 |   ) % (x, y)
93 |
94 | / (
95 | |     "foo %(foo)s "
96 | |     "bar %(bar)s"
97 | | ) % {"foo": x, "bar": y}
   | |________________________^
98 |
99 |   (
   |
help: Replace with format specifiers
   |
94 | (
   -     "foo %(foo)s "
   -     "bar %(bar)s"
   - ) % {"foo": x, "bar": y}
95 +     "foo {foo} "
96 +     "bar {bar}"
97 + ).format(foo=x, bar=y)
98 |
   |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:100:5
    |
 99 |   (
100 | /     """foo %s"""
101 | |     % (x,)
    | |__________^
102 |   )
    |
help: Replace with format specifiers
    |
99  | (
    -     """foo %s"""
    -     % (x,)
100 +     """foo {}""".format(x)
101 | )
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:105:5
    |
104 |   (
105 | /     """
106 | |     foo %s
107 | |     """
108 | |     % (x,)
    | |__________^
109 |   )
    |
help: Replace with format specifiers
    |
105 |     """
    -     foo %s
    -     """
    -     % (x,)
106 +     foo {}
107 +     """.format(x)
108 | )
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:111:1
    |
109 |   )
110 |
111 | / "%s" % (
112 | |     x,  # comment
113 | | )
    | |_^
    |
help: Replace with format specifiers
    |
110 |
    - "%s" % (
111 + "{}".format(
112 |     x,  # comment
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:116:8
    |
116 |   path = "%s-%s-%s.pem" % (
    |  ________^
117 | |     safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert ma…
118 | |     cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date
119 | |     hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix
120 | | )
    | |_^
121 |
122 |   # UP031 (no longer false negatives; now offer potentially unsafe fixes)
    |
help: Replace with format specifiers
    |
115 |
    - path = "%s-%s-%s.pem" % (
116 + path = "{}-{}-{}.pem".format(
117 |     safe_domain_name(cn), # common name, which should be filename safe because it is IDNA-encoded, but in case of a malformed cert make sure it's ok to use as a filename
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:123:1
    |
122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes)
123 | 'Hello %s' % bar
    | ^^^^^^^^^^^^^^^^
124 |
125 | 'Hello %s' % bar.baz
    |
help: Replace with format specifiers
    |
122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes)
    - 'Hello %s' % bar
123 + 'Hello {}'.format(bar)
124 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:125:1
    |
123 | 'Hello %s' % bar
124 |
125 | 'Hello %s' % bar.baz
    | ^^^^^^^^^^^^^^^^^^^^
126 |
127 | 'Hello %s' % bar['bop']
    |
help: Replace with format specifiers
    |
124 |
    - 'Hello %s' % bar.baz
125 + 'Hello {}'.format(bar.baz)
126 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:127:1
    |
125 | 'Hello %s' % bar.baz
126 |
127 | 'Hello %s' % bar['bop']
    | ^^^^^^^^^^^^^^^^^^^^^^^
128 |
129 | # Not a valid type annotation but this test shouldn't result in a panic.
    |
help: Replace with format specifiers
    |
126 |
    - 'Hello %s' % bar['bop']
127 + 'Hello {}'.format(bar['bop'])
128 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:131:5
    |
129 | # Not a valid type annotation but this test shouldn't result in a panic.
130 | # Refer: https://github.com/astral-sh/ruff/issues/11736
131 | x: "'%s + %s' % (1, 2)"
    |     ^^^^^^^^^^^^^^^^^^
132 |
133 | # See: https://github.com/astral-sh/ruff/issues/12421
    |
help: Replace with format specifiers
    |
130 | # Refer: https://github.com/astral-sh/ruff/issues/11736
    - x: "'%s + %s' % (1, 2)"
131 + x: "'{} + {}'.format(1, 2)"
132 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:134:7
    |
133 | # See: https://github.com/astral-sh/ruff/issues/12421
134 | print("%.2X" % 1)
    |       ^^^^^^^^^^
135 | print("%.02X" % 1)
136 | print("%02X" % 1)
    |
help: Replace with format specifiers
    |
133 | # See: https://github.com/astral-sh/ruff/issues/12421
    - print("%.2X" % 1)
134 + print("{:02X}".format(1))
135 | print("%.02X" % 1)
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:135:7
    |
133 | # See: https://github.com/astral-sh/ruff/issues/12421
134 | print("%.2X" % 1)
135 | print("%.02X" % 1)
    |       ^^^^^^^^^^^
136 | print("%02X" % 1)
137 | print("%.00002X" % 1)
    |
help: Replace with format specifiers
    |
134 | print("%.2X" % 1)
    - print("%.02X" % 1)
135 + print("{:02X}".format(1))
136 | print("%02X" % 1)
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:136:7
    |
134 | print("%.2X" % 1)
135 | print("%.02X" % 1)
136 | print("%02X" % 1)
    |       ^^^^^^^^^^
137 | print("%.00002X" % 1)
138 | print("%.20X" % 1)
    |
help: Replace with format specifiers
    |
135 | print("%.02X" % 1)
    - print("%02X" % 1)
136 + print("{:02X}".format(1))
137 | print("%.00002X" % 1)
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:137:7
    |
135 | print("%.02X" % 1)
136 | print("%02X" % 1)
137 | print("%.00002X" % 1)
    |       ^^^^^^^^^^^^^^
138 | print("%.20X" % 1)
    |
help: Replace with format specifiers
    |
136 | print("%02X" % 1)
    - print("%.00002X" % 1)
137 + print("{:02X}".format(1))
138 | print("%.20X" % 1)
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:138:7
    |
136 | print("%02X" % 1)
137 | print("%.00002X" % 1)
138 | print("%.20X" % 1)
    |       ^^^^^^^^^^^
139 |
140 | print("%2X" % 1)
    |
help: Replace with format specifiers
    |
137 | print("%.00002X" % 1)
    - print("%.20X" % 1)
138 + print("{:020X}".format(1))
139 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:140:7
    |
138 | print("%.20X" % 1)
139 |
140 | print("%2X" % 1)
    |       ^^^^^^^^^
141 | print("%02X" % 1)
    |
help: Replace with format specifiers
    |
139 |
    - print("%2X" % 1)
140 + print("{:2X}".format(1))
141 | print("%02X" % 1)
    |
note: This is an unsafe fix and may change runtime behavior

UP031 [*] Use format specifiers instead of percent format
   --> UP031_0.py:141:7
    |
140 | print("%2X" % 1)
141 | print("%02X" % 1)
    |       ^^^^^^^^^^
142 |
143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax)
    |
help: Replace with format specifiers
    |
140 | print("%2X" % 1)
    - print("%02X" % 1)
141 + print("{:02X}".format(1))
142 |
    |
note: This is an unsafe fix and may change runtime behavior

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:145:1
    |
143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax)
144 |
145 | "%d.%d" % (a, b)
    | ^^^^^^^
146 |
147 | "%*s" % (5, "hi")
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:147:1
    |
145 | "%d.%d" % (a, b)
146 |
147 | "%*s" % (5, "hi")
    | ^^^^^
148 |
149 | "%d" % (flt,)
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:149:1
    |
147 | "%*s" % (5, "hi")
148 |
149 | "%d" % (flt,)
    | ^^^^
150 |
151 | "%c" % (some_string,)
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:151:1
    |
149 | "%d" % (flt,)
150 |
151 | "%c" % (some_string,)
    | ^^^^
152 |
153 | "%.2r" % (1.25)
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:153:1
    |
151 | "%c" % (some_string,)
152 |
153 | "%.2r" % (1.25)
    | ^^^^^^
154 |
155 | "%.*s" % (5, "hi")
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:155:1
    |
153 | "%.2r" % (1.25)
154 |
155 | "%.*s" % (5, "hi")
    | ^^^^^^
156 |
157 | "%i" % (flt,)
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:157:1
    |
155 | "%.*s" % (5, "hi")
156 |
157 | "%i" % (flt,)
    | ^^^^
158 |
159 | "%()s" % {"": "empty"}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:159:1
    |
157 | "%i" % (flt,)
158 |
159 | "%()s" % {"": "empty"}
    | ^^^^^^
160 |
161 | "%s" % {"k": "v"}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:161:1
    |
159 | "%()s" % {"": "empty"}
160 |
161 | "%s" % {"k": "v"}
    | ^^^^
162 |
163 | "%()s" % {"": "bar"}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:163:1
    |
161 | "%s" % {"k": "v"}
162 |
163 | "%()s" % {"": "bar"}
    | ^^^^^^
164 |
165 | "%(1)s" % {"1": "bar"}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:165:1
    |
163 | "%()s" % {"": "bar"}
164 |
165 | "%(1)s" % {"1": "bar"}
    | ^^^^^^^
166 |
167 | "%(a)s" % {"a": 1, "a": 2}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:167:1
    |
165 | "%(1)s" % {"1": "bar"}
166 |
167 | "%(a)s" % {"a": 1, "a": 2}
    | ^^^^^^^
168 |
169 | "%(1)s" % {1: 2, "1": 2}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:169:1
    |
167 | "%(a)s" % {"a": 1, "a": 2}
168 |
169 | "%(1)s" % {1: 2, "1": 2}
    | ^^^^^^^
170 |
171 | "%(and)s" % {"and": 2}
    |
help: Replace with format specifiers

UP031 Use format specifiers instead of percent format
   --> UP031_0.py:171:1
    |
169 | "%(1)s" % {1: 2, "1": 2}
170 |
171 | "%(and)s" % {"and": 2}
    | ^^^^^^^^^
    |
help: Replace with format specifiers
