mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-03 13:23:10 +00:00
[ruff] Suppress diagnostic for f-string interpolations with debug text (RUF010) (#20525)
## Summary Fixes #20519
This commit is contained in:
parent
2be73e9afb
commit
1bf4969c96
3 changed files with 18 additions and 16 deletions
|
|
@ -56,3 +56,11 @@ f"{str(object=3)}"
|
|||
f"{str(x for x in [])}"
|
||||
|
||||
f"{str((x for x in []))}"
|
||||
|
||||
# Debug text cases - should not trigger RUF010
|
||||
f"{str(1)=}"
|
||||
f"{ascii(1)=}"
|
||||
f"{repr(1)=}"
|
||||
f"{str('hello')=}"
|
||||
f"{ascii('hello')=}"
|
||||
f"{repr('hello')=}"
|
||||
|
|
|
|||
|
|
@ -110,10 +110,7 @@ pub(crate) fn explicit_f_string_type_conversion(checker: &Checker, f_string: &as
|
|||
return;
|
||||
}
|
||||
|
||||
let mut diagnostic =
|
||||
checker.report_diagnostic(ExplicitFStringTypeConversion, expression.range());
|
||||
|
||||
// Don't support fixing f-string with debug text.
|
||||
// Don't report diagnostic for f-string with debug text.
|
||||
if element
|
||||
.as_interpolation()
|
||||
.is_some_and(|interpolation| interpolation.debug_text.is_some())
|
||||
|
|
@ -121,6 +118,9 @@ pub(crate) fn explicit_f_string_type_conversion(checker: &Checker, f_string: &as
|
|||
return;
|
||||
}
|
||||
|
||||
let mut diagnostic =
|
||||
checker.report_diagnostic(ExplicitFStringTypeConversion, expression.range());
|
||||
|
||||
diagnostic.try_set_fix(|| {
|
||||
convert_call_to_conversion_flag(checker, conversion, f_string, index, arg)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -293,18 +293,6 @@ help: Replace with conversion flag
|
|||
48 | f"{repr(1)=}"
|
||||
49 |
|
||||
|
||||
RUF010 Use explicit conversion flag
|
||||
--> RUF010.py:48:4
|
||||
|
|
||||
46 | f"{builtins.repr(1)}"
|
||||
47 |
|
||||
48 | f"{repr(1)=}"
|
||||
| ^^^^^^^
|
||||
49 |
|
||||
50 | f"{repr(lambda: 1)}"
|
||||
|
|
||||
help: Replace with conversion flag
|
||||
|
||||
RUF010 [*] Use explicit conversion flag
|
||||
--> RUF010.py:50:4
|
||||
|
|
||||
|
|
@ -383,6 +371,7 @@ help: Replace with conversion flag
|
|||
56 + f"{(x for x in [])!s}"
|
||||
57 |
|
||||
58 | f"{str((x for x in []))}"
|
||||
59 |
|
||||
|
||||
RUF010 [*] Use explicit conversion flag
|
||||
--> RUF010.py:58:4
|
||||
|
|
@ -391,6 +380,8 @@ RUF010 [*] Use explicit conversion flag
|
|||
57 |
|
||||
58 | f"{str((x for x in []))}"
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
59 |
|
||||
60 | # Debug text cases - should not trigger RUF010
|
||||
|
|
||||
help: Replace with conversion flag
|
||||
55 |
|
||||
|
|
@ -398,3 +389,6 @@ help: Replace with conversion flag
|
|||
57 |
|
||||
- f"{str((x for x in []))}"
|
||||
58 + f"{(x for x in [])!s}"
|
||||
59 |
|
||||
60 | # Debug text cases - should not trigger RUF010
|
||||
61 | f"{str(1)=}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue