Skip to content

Commit 0782cec

Browse files
T-256konstin
authored andcommitted
UP018: Improve Fix message (#7913)
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> closes #7912 ## Test Plan <!-- How was it tested? -->
1 parent 3386729 commit 0782cec

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ impl AlwaysFixableViolation for NativeLiterals {
117117
fn fix_title(&self) -> String {
118118
let NativeLiterals { literal_type } = self;
119119
match literal_type {
120-
LiteralType::Str => "Replace with empty string".to_string(),
121-
LiteralType::Bytes => "Replace with empty bytes".to_string(),
122-
LiteralType::Int => "Replace with 0".to_string(),
123-
LiteralType::Float => "Replace with 0.0".to_string(),
124-
LiteralType::Bool => "Replace with `False`".to_string(),
120+
LiteralType::Str => "Replace with string literal".to_string(),
121+
LiteralType::Bytes => "Replace with bytes literal".to_string(),
122+
LiteralType::Int => "Replace with integer literal".to_string(),
123+
LiteralType::Float => "Replace with float literal".to_string(),
124+
LiteralType::Bool => "Replace with boolean literal".to_string(),
125125
}
126126
}
127127
}

crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal)
99
38 | str("foo")
1010
39 | str("""
1111
|
12-
= help: Replace with empty string
12+
= help: Replace with string literal
1313

1414
Fix
1515
34 34 | int().denominator
@@ -30,7 +30,7 @@ UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal)
3030
39 | str("""
3131
40 | foo""")
3232
|
33-
= help: Replace with empty string
33+
= help: Replace with string literal
3434

3535
Fix
3636
35 35 |
@@ -52,7 +52,7 @@ UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal)
5252
41 | bytes()
5353
42 | bytes(b"foo")
5454
|
55-
= help: Replace with empty string
55+
= help: Replace with string literal
5656

5757
Fix
5858
36 36 | # These become string or byte literals
@@ -75,7 +75,7 @@ UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal)
7575
42 | bytes(b"foo")
7676
43 | bytes(b"""
7777
|
78-
= help: Replace with empty bytes
78+
= help: Replace with bytes literal
7979

8080
Fix
8181
38 38 | str("foo")
@@ -96,7 +96,7 @@ UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal)
9696
43 | bytes(b"""
9797
44 | foo""")
9898
|
99-
= help: Replace with empty bytes
99+
= help: Replace with bytes literal
100100

101101
Fix
102102
39 39 | str("""
@@ -118,7 +118,7 @@ UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal)
118118
45 | f"{str()}"
119119
46 | int()
120120
|
121-
= help: Replace with empty bytes
121+
= help: Replace with bytes literal
122122

123123
Fix
124124
40 40 | foo""")
@@ -141,7 +141,7 @@ UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal)
141141
46 | int()
142142
47 | int(1)
143143
|
144-
= help: Replace with empty string
144+
= help: Replace with string literal
145145

146146
Fix
147147
42 42 | bytes(b"foo")
@@ -162,7 +162,7 @@ UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal)
162162
47 | int(1)
163163
48 | float()
164164
|
165-
= help: Replace with 0
165+
= help: Replace with integer literal
166166

167167
Fix
168168
43 43 | bytes(b"""
@@ -183,7 +183,7 @@ UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal)
183183
48 | float()
184184
49 | float(1.0)
185185
|
186-
= help: Replace with 0
186+
= help: Replace with integer literal
187187

188188
Fix
189189
44 44 | foo""")
@@ -204,7 +204,7 @@ UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal)
204204
49 | float(1.0)
205205
50 | bool()
206206
|
207-
= help: Replace with 0.0
207+
= help: Replace with float literal
208208

209209
Fix
210210
45 45 | f"{str()}"
@@ -225,7 +225,7 @@ UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal)
225225
50 | bool()
226226
51 | bool(True)
227227
|
228-
= help: Replace with 0.0
228+
= help: Replace with float literal
229229

230230
Fix
231231
46 46 | int()
@@ -246,7 +246,7 @@ UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal)
246246
51 | bool(True)
247247
52 | bool(False)
248248
|
249-
= help: Replace with `False`
249+
= help: Replace with boolean literal
250250

251251
Fix
252252
47 47 | int(1)
@@ -266,7 +266,7 @@ UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal)
266266
| ^^^^^^^^^^ UP018
267267
52 | bool(False)
268268
|
269-
= help: Replace with `False`
269+
= help: Replace with boolean literal
270270

271271
Fix
272272
48 48 | float()
@@ -287,7 +287,7 @@ UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal)
287287
53 |
288288
54 | # These become a literal but retain parentheses
289289
|
290-
= help: Replace with `False`
290+
= help: Replace with boolean literal
291291

292292
Fix
293293
49 49 | float(1.0)
@@ -305,7 +305,7 @@ UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal)
305305
55 | int(1).denominator
306306
| ^^^^^^ UP018
307307
|
308-
= help: Replace with 0
308+
= help: Replace with integer literal
309309

310310
Fix
311311
52 52 | bool(False)

0 commit comments

Comments
 (0)