Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UP018: Improve Fix message #7913

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ impl AlwaysFixableViolation for NativeLiterals {
fn fix_title(&self) -> String {
let NativeLiterals { literal_type } = self;
match literal_type {
LiteralType::Str => "Replace with empty string".to_string(),
LiteralType::Bytes => "Replace with empty bytes".to_string(),
LiteralType::Int => "Replace with 0".to_string(),
LiteralType::Float => "Replace with 0.0".to_string(),
LiteralType::Bool => "Replace with `False`".to_string(),
LiteralType::Str => "Replace with string literal".to_string(),
LiteralType::Bytes => "Replace with bytes literal".to_string(),
LiteralType::Int => "Replace with integer literal".to_string(),
LiteralType::Float => "Replace with float literal".to_string(),
LiteralType::Bool => "Replace with boolean literal".to_string(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal)
38 | str("foo")
39 | str("""
|
= help: Replace with empty string
= help: Replace with string literal

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

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

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

ℹ Fix
38 38 | str("foo")
Expand All @@ -96,7 +96,7 @@ UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal)
43 | bytes(b"""
44 | foo""")
|
= help: Replace with empty bytes
= help: Replace with bytes literal

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

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

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

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

ℹ Fix
44 44 | foo""")
Expand All @@ -204,7 +204,7 @@ UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal)
49 | float(1.0)
50 | bool()
|
= help: Replace with 0.0
= help: Replace with float literal

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

ℹ Fix
46 46 | int()
Expand All @@ -246,7 +246,7 @@ UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal)
51 | bool(True)
52 | bool(False)
|
= help: Replace with `False`
= help: Replace with boolean literal

ℹ Fix
47 47 | int(1)
Expand All @@ -266,7 +266,7 @@ UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal)
| ^^^^^^^^^^ UP018
52 | bool(False)
|
= help: Replace with `False`
= help: Replace with boolean literal

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

ℹ Fix
49 49 | float(1.0)
Expand All @@ -305,7 +305,7 @@ UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal)
55 | int(1).denominator
| ^^^^^^ UP018
|
= help: Replace with 0
= help: Replace with integer literal

ℹ Fix
52 52 | bool(False)
Expand Down
Loading