From 3fe9540a707f739819d4d7e71ee3bf13db43d4eb Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 30 Sep 2025 20:21:39 -0400 Subject: [PATCH 1/2] fix-20583 --- .../resources/test/fixtures/ruff/RUF065.py | 31 +++ .../ruff/rules/logging_eager_conversion.rs | 106 +++++++-- ..._rules__ruff__tests__RUF065_RUF065.py.snap | 219 ++++++++++++++++++ 3 files changed, 342 insertions(+), 14 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py index d7de9df7d2372b..82cc8cc10e2490 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py @@ -43,3 +43,34 @@ def str(s): return f"str = {s}" logging.error("Error: %r", repr([1, 2, 3])) logging.info("Debug info: %s", repr("test\nstring")) logging.warning("Value: %s", repr(42)) + +# %s + ascii() +logging.info("ASCII: %s", ascii("Hello\nWorld")) +logging.warning("ASCII: %s", ascii("test")) + +# %s + oct() +logging.info("Octal: %s", oct(42)) +logging.warning("Octal: %s", oct(255)) + +# %s + hex() +logging.info("Hex: %s", hex(42)) +logging.warning("Hex: %s", hex(255)) + +# %b + bytes() +logging.info("Bytes: %b", bytes("Hello", "utf-8")) +logging.warning("Bytes: %b", bytes("test", "utf-8")) + +# Test with imported functions +from logging import info, log + +info("ASCII: %s", ascii("Hello\nWorld")) +log(logging.INFO, "ASCII: %s", ascii("test")) + +info("Octal: %s", oct(42)) +log(logging.INFO, "Octal: %s", oct(255)) + +info("Hex: %s", hex(42)) +log(logging.INFO, "Hex: %s", hex(255)) + +info("Bytes: %b", bytes("Hello", "utf-8")) +log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) diff --git a/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs b/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs index 1567cea1d674a3..24af77bfee7697 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs @@ -62,19 +62,24 @@ use crate::rules::flake8_logging_format::rules::{LoggingCallType, find_logging_c #[derive(ViolationMetadata)] pub(crate) struct LoggingEagerConversion { pub(crate) format_conversion: FormatConversion, + pub(crate) function_name: Option, } impl Violation for LoggingEagerConversion { #[derive_message_formats] fn message(&self) -> String { - let LoggingEagerConversion { format_conversion } = self; - let (format_str, call_arg) = match format_conversion { - FormatConversion::Str => ("%s", "str()"), - FormatConversion::Repr => ("%r", "repr()"), - FormatConversion::Ascii => ("%a", "ascii()"), - FormatConversion::Bytes => ("%b", "bytes()"), - }; - format!("Unnecessary `{call_arg}` conversion when formatting with `{format_str}`") + let LoggingEagerConversion { + format_conversion, + function_name, + } = self; + match (format_conversion, function_name.as_deref()) { + (FormatConversion::Str, Some("oct")) => "Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s`".to_string(), + (FormatConversion::Str, Some("hex")) => "Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s`".to_string(), + (FormatConversion::Str, _) => "Unnecessary `str()` conversion when formatting with `%s`".to_string(), + (FormatConversion::Repr, _) => "Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s`".to_string(), + (FormatConversion::Ascii, _) => "Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s`".to_string(), + (FormatConversion::Bytes, _) => "Unnecessary `bytes()` conversion when formatting with `%b`".to_string(), + } } } @@ -117,12 +122,85 @@ pub(crate) fn logging_eager_conversion(checker: &Checker, call: &ast::ExprCall) continue; }; - // Check for use of %s with str() - if checker.semantic().match_builtin_expr(func.as_ref(), "str") - && matches!(format_conversion, FormatConversion::Str) - { - checker - .report_diagnostic(LoggingEagerConversion { format_conversion }, arg.range()); + // Check for various eager conversion patterns + match format_conversion { + // %s with str() - remove str() call + FormatConversion::Str + if checker.semantic().match_builtin_expr(func.as_ref(), "str") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion, + function_name: None, + }, + arg.range(), + ); + } + // %s with repr() - suggest using %r instead + FormatConversion::Str + if checker.semantic().match_builtin_expr(func.as_ref(), "repr") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion: FormatConversion::Repr, + function_name: None, + }, + arg.range(), + ); + } + // %s with ascii() - suggest using %a instead + FormatConversion::Str + if checker + .semantic() + .match_builtin_expr(func.as_ref(), "ascii") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion: FormatConversion::Ascii, + function_name: None, + }, + arg.range(), + ); + } + // %s with oct() - suggest using %#o instead + FormatConversion::Str + if checker.semantic().match_builtin_expr(func.as_ref(), "oct") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion: FormatConversion::Str, + function_name: Some("oct".to_string()), + }, + arg.range(), + ); + } + // %s with hex() - suggest using %#x instead + FormatConversion::Str + if checker.semantic().match_builtin_expr(func.as_ref(), "hex") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion: FormatConversion::Str, + function_name: Some("hex".to_string()), + }, + arg.range(), + ); + } + // %b with bytes() - remove bytes() call + FormatConversion::Bytes + if checker + .semantic() + .match_builtin_expr(func.as_ref(), "bytes") => + { + checker.report_diagnostic( + LoggingEagerConversion { + format_conversion, + function_name: None, + }, + arg.range(), + ); + } + _ => {} } } } diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap index 9589c4555deda2..bb0027217f8789 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap @@ -21,6 +21,26 @@ RUF065 Unnecessary `str()` conversion when formatting with `%s` 7 | # %s + repr() | +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:8:26 + | +7 | # %s + repr() +8 | logging.info("Hello %s", repr("World!")) + | ^^^^^^^^^^^^^^ +9 | logging.log(logging.INFO, "Hello %s", repr("World!")) + | + +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:9:39 + | + 7 | # %s + repr() + 8 | logging.info("Hello %s", repr("World!")) + 9 | logging.log(logging.INFO, "Hello %s", repr("World!")) + | ^^^^^^^^^^^^^^ +10 | +11 | # %r + str() + | + RUF065 Unnecessary `str()` conversion when formatting with `%s` --> RUF065.py:22:18 | @@ -40,3 +60,202 @@ RUF065 Unnecessary `str()` conversion when formatting with `%s` 24 | 25 | # %s + repr() | + +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:26:18 + | +25 | # %s + repr() +26 | info("Hello %s", repr("World!")) + | ^^^^^^^^^^^^^^ +27 | log(logging.INFO, "Hello %s", repr("World!")) + | + +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:27:31 + | +25 | # %s + repr() +26 | info("Hello %s", repr("World!")) +27 | log(logging.INFO, "Hello %s", repr("World!")) + | ^^^^^^^^^^^^^^ +28 | +29 | # %r + str() + | + +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:44:32 + | +42 | logging.warning("Value: %r", repr(42)) +43 | logging.error("Error: %r", repr([1, 2, 3])) +44 | logging.info("Debug info: %s", repr("test\nstring")) + | ^^^^^^^^^^^^^^^^^^^^ +45 | logging.warning("Value: %s", repr(42)) + | + +RUF065 Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s` + --> RUF065.py:45:30 + | +43 | logging.error("Error: %r", repr([1, 2, 3])) +44 | logging.info("Debug info: %s", repr("test\nstring")) +45 | logging.warning("Value: %s", repr(42)) + | ^^^^^^^^ +46 | +47 | # %s + ascii() + | + +RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` + --> RUF065.py:48:27 + | +47 | # %s + ascii() +48 | logging.info("ASCII: %s", ascii("Hello\nWorld")) + | ^^^^^^^^^^^^^^^^^^^^^ +49 | logging.warning("ASCII: %s", ascii("test")) + | + +RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` + --> RUF065.py:49:30 + | +47 | # %s + ascii() +48 | logging.info("ASCII: %s", ascii("Hello\nWorld")) +49 | logging.warning("ASCII: %s", ascii("test")) + | ^^^^^^^^^^^^^ +50 | +51 | # %s + oct() + | + +RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` + --> RUF065.py:52:27 + | +51 | # %s + oct() +52 | logging.info("Octal: %s", oct(42)) + | ^^^^^^^ +53 | logging.warning("Octal: %s", oct(255)) + | + +RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` + --> RUF065.py:53:30 + | +51 | # %s + oct() +52 | logging.info("Octal: %s", oct(42)) +53 | logging.warning("Octal: %s", oct(255)) + | ^^^^^^^^ +54 | +55 | # %s + hex() + | + +RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` + --> RUF065.py:56:25 + | +55 | # %s + hex() +56 | logging.info("Hex: %s", hex(42)) + | ^^^^^^^ +57 | logging.warning("Hex: %s", hex(255)) + | + +RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` + --> RUF065.py:57:28 + | +55 | # %s + hex() +56 | logging.info("Hex: %s", hex(42)) +57 | logging.warning("Hex: %s", hex(255)) + | ^^^^^^^^ +58 | +59 | # %b + bytes() + | + +RUF065 Unnecessary `bytes()` conversion when formatting with `%b` + --> RUF065.py:60:27 + | +59 | # %b + bytes() +60 | logging.info("Bytes: %b", bytes("Hello", "utf-8")) + | ^^^^^^^^^^^^^^^^^^^^^^^ +61 | logging.warning("Bytes: %b", bytes("test", "utf-8")) + | + +RUF065 Unnecessary `bytes()` conversion when formatting with `%b` + --> RUF065.py:61:30 + | +59 | # %b + bytes() +60 | logging.info("Bytes: %b", bytes("Hello", "utf-8")) +61 | logging.warning("Bytes: %b", bytes("test", "utf-8")) + | ^^^^^^^^^^^^^^^^^^^^^^ +62 | +63 | # Test with imported functions + | + +RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` + --> RUF065.py:66:19 + | +64 | from logging import info, log +65 | +66 | info("ASCII: %s", ascii("Hello\nWorld")) + | ^^^^^^^^^^^^^^^^^^^^^ +67 | log(logging.INFO, "ASCII: %s", ascii("test")) + | + +RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` + --> RUF065.py:67:32 + | +66 | info("ASCII: %s", ascii("Hello\nWorld")) +67 | log(logging.INFO, "ASCII: %s", ascii("test")) + | ^^^^^^^^^^^^^ +68 | +69 | info("Octal: %s", oct(42)) + | + +RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` + --> RUF065.py:69:19 + | +67 | log(logging.INFO, "ASCII: %s", ascii("test")) +68 | +69 | info("Octal: %s", oct(42)) + | ^^^^^^^ +70 | log(logging.INFO, "Octal: %s", oct(255)) + | + +RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` + --> RUF065.py:70:32 + | +69 | info("Octal: %s", oct(42)) +70 | log(logging.INFO, "Octal: %s", oct(255)) + | ^^^^^^^^ +71 | +72 | info("Hex: %s", hex(42)) + | + +RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` + --> RUF065.py:72:17 + | +70 | log(logging.INFO, "Octal: %s", oct(255)) +71 | +72 | info("Hex: %s", hex(42)) + | ^^^^^^^ +73 | log(logging.INFO, "Hex: %s", hex(255)) + | + +RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` + --> RUF065.py:73:30 + | +72 | info("Hex: %s", hex(42)) +73 | log(logging.INFO, "Hex: %s", hex(255)) + | ^^^^^^^^ +74 | +75 | info("Bytes: %b", bytes("Hello", "utf-8")) + | + +RUF065 Unnecessary `bytes()` conversion when formatting with `%b` + --> RUF065.py:75:19 + | +73 | log(logging.INFO, "Hex: %s", hex(255)) +74 | +75 | info("Bytes: %b", bytes("Hello", "utf-8")) + | ^^^^^^^^^^^^^^^^^^^^^^^ +76 | log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) + | + +RUF065 Unnecessary `bytes()` conversion when formatting with `%b` + --> RUF065.py:76:32 + | +75 | info("Bytes: %b", bytes("Hello", "utf-8")) +76 | log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) + | ^^^^^^^^^^^^^^^^^^^^^^ + | From cbb9c0977a6e01a82f8c406fb75c9d867fce6679 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 15 Oct 2025 19:40:07 -0400 Subject: [PATCH 2/2] Remove `bytes()` eager conversion checks from RUF065, refactor --- .../resources/test/fixtures/ruff/RUF065.py | 5 - .../ruff/rules/logging_eager_conversion.rs | 52 +++++----- ..._rules__ruff__tests__RUF065_RUF065.py.snap | 98 ++++++------------- 3 files changed, 57 insertions(+), 98 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py index 82cc8cc10e2490..879fb186bf543b 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF065.py @@ -56,9 +56,6 @@ def str(s): return f"str = {s}" logging.info("Hex: %s", hex(42)) logging.warning("Hex: %s", hex(255)) -# %b + bytes() -logging.info("Bytes: %b", bytes("Hello", "utf-8")) -logging.warning("Bytes: %b", bytes("test", "utf-8")) # Test with imported functions from logging import info, log @@ -72,5 +69,3 @@ def str(s): return f"str = {s}" info("Hex: %s", hex(42)) log(logging.INFO, "Hex: %s", hex(255)) -info("Bytes: %b", bytes("Hello", "utf-8")) -log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) diff --git a/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs b/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs index 24af77bfee7697..01ee5549baff48 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/logging_eager_conversion.rs @@ -62,7 +62,7 @@ use crate::rules::flake8_logging_format::rules::{LoggingCallType, find_logging_c #[derive(ViolationMetadata)] pub(crate) struct LoggingEagerConversion { pub(crate) format_conversion: FormatConversion, - pub(crate) function_name: Option, + pub(crate) function_name: Option<&'static str>, } impl Violation for LoggingEagerConversion { @@ -73,12 +73,32 @@ impl Violation for LoggingEagerConversion { function_name, } = self; match (format_conversion, function_name.as_deref()) { - (FormatConversion::Str, Some("oct")) => "Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s`".to_string(), - (FormatConversion::Str, Some("hex")) => "Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s`".to_string(), - (FormatConversion::Str, _) => "Unnecessary `str()` conversion when formatting with `%s`".to_string(), - (FormatConversion::Repr, _) => "Unnecessary `repr()` conversion when formatting with `%s`. Use `%r` instead of `%s`".to_string(), - (FormatConversion::Ascii, _) => "Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s`".to_string(), - (FormatConversion::Bytes, _) => "Unnecessary `bytes()` conversion when formatting with `%b`".to_string(), + (FormatConversion::Str, Some("oct")) => { + "Unnecessary `oct()` conversion when formatting with `%s`. \ + Use `%#o` instead of `%s`" + .to_string() + } + (FormatConversion::Str, Some("hex")) => { + "Unnecessary `hex()` conversion when formatting with `%s`. \ + Use `%#x` instead of `%s`" + .to_string() + } + (FormatConversion::Str, _) => { + "Unnecessary `str()` conversion when formatting with `%s`".to_string() + } + (FormatConversion::Repr, _) => { + "Unnecessary `repr()` conversion when formatting with `%s`. \ + Use `%r` instead of `%s`" + .to_string() + } + (FormatConversion::Ascii, _) => { + "Unnecessary `ascii()` conversion when formatting with `%s`. \ + Use `%a` instead of `%s`" + .to_string() + } + (FormatConversion::Bytes, _) => { + "Unnecessary `bytes()` conversion when formatting with `%b`".to_string() + } } } } @@ -169,7 +189,7 @@ pub(crate) fn logging_eager_conversion(checker: &Checker, call: &ast::ExprCall) checker.report_diagnostic( LoggingEagerConversion { format_conversion: FormatConversion::Str, - function_name: Some("oct".to_string()), + function_name: Some("oct"), }, arg.range(), ); @@ -181,21 +201,7 @@ pub(crate) fn logging_eager_conversion(checker: &Checker, call: &ast::ExprCall) checker.report_diagnostic( LoggingEagerConversion { format_conversion: FormatConversion::Str, - function_name: Some("hex".to_string()), - }, - arg.range(), - ); - } - // %b with bytes() - remove bytes() call - FormatConversion::Bytes - if checker - .semantic() - .match_builtin_expr(func.as_ref(), "bytes") => - { - checker.report_diagnostic( - LoggingEagerConversion { - format_conversion, - function_name: None, + function_name: Some("hex"), }, arg.range(), ); diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap index bb0027217f8789..9f96c363073381 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF065_RUF065.py.snap @@ -158,104 +158,62 @@ RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` inste 56 | logging.info("Hex: %s", hex(42)) 57 | logging.warning("Hex: %s", hex(255)) | ^^^^^^^^ -58 | -59 | # %b + bytes() - | - -RUF065 Unnecessary `bytes()` conversion when formatting with `%b` - --> RUF065.py:60:27 - | -59 | # %b + bytes() -60 | logging.info("Bytes: %b", bytes("Hello", "utf-8")) - | ^^^^^^^^^^^^^^^^^^^^^^^ -61 | logging.warning("Bytes: %b", bytes("test", "utf-8")) - | - -RUF065 Unnecessary `bytes()` conversion when formatting with `%b` - --> RUF065.py:61:30 - | -59 | # %b + bytes() -60 | logging.info("Bytes: %b", bytes("Hello", "utf-8")) -61 | logging.warning("Bytes: %b", bytes("test", "utf-8")) - | ^^^^^^^^^^^^^^^^^^^^^^ -62 | -63 | # Test with imported functions | RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` - --> RUF065.py:66:19 + --> RUF065.py:63:19 | -64 | from logging import info, log -65 | -66 | info("ASCII: %s", ascii("Hello\nWorld")) +61 | from logging import info, log +62 | +63 | info("ASCII: %s", ascii("Hello\nWorld")) | ^^^^^^^^^^^^^^^^^^^^^ -67 | log(logging.INFO, "ASCII: %s", ascii("test")) +64 | log(logging.INFO, "ASCII: %s", ascii("test")) | RUF065 Unnecessary `ascii()` conversion when formatting with `%s`. Use `%a` instead of `%s` - --> RUF065.py:67:32 + --> RUF065.py:64:32 | -66 | info("ASCII: %s", ascii("Hello\nWorld")) -67 | log(logging.INFO, "ASCII: %s", ascii("test")) +63 | info("ASCII: %s", ascii("Hello\nWorld")) +64 | log(logging.INFO, "ASCII: %s", ascii("test")) | ^^^^^^^^^^^^^ -68 | -69 | info("Octal: %s", oct(42)) +65 | +66 | info("Octal: %s", oct(42)) | RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` - --> RUF065.py:69:19 + --> RUF065.py:66:19 | -67 | log(logging.INFO, "ASCII: %s", ascii("test")) -68 | -69 | info("Octal: %s", oct(42)) +64 | log(logging.INFO, "ASCII: %s", ascii("test")) +65 | +66 | info("Octal: %s", oct(42)) | ^^^^^^^ -70 | log(logging.INFO, "Octal: %s", oct(255)) +67 | log(logging.INFO, "Octal: %s", oct(255)) | RUF065 Unnecessary `oct()` conversion when formatting with `%s`. Use `%#o` instead of `%s` - --> RUF065.py:70:32 + --> RUF065.py:67:32 | -69 | info("Octal: %s", oct(42)) -70 | log(logging.INFO, "Octal: %s", oct(255)) +66 | info("Octal: %s", oct(42)) +67 | log(logging.INFO, "Octal: %s", oct(255)) | ^^^^^^^^ -71 | -72 | info("Hex: %s", hex(42)) +68 | +69 | info("Hex: %s", hex(42)) | RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` - --> RUF065.py:72:17 + --> RUF065.py:69:17 | -70 | log(logging.INFO, "Octal: %s", oct(255)) -71 | -72 | info("Hex: %s", hex(42)) +67 | log(logging.INFO, "Octal: %s", oct(255)) +68 | +69 | info("Hex: %s", hex(42)) | ^^^^^^^ -73 | log(logging.INFO, "Hex: %s", hex(255)) +70 | log(logging.INFO, "Hex: %s", hex(255)) | RUF065 Unnecessary `hex()` conversion when formatting with `%s`. Use `%#x` instead of `%s` - --> RUF065.py:73:30 + --> RUF065.py:70:30 | -72 | info("Hex: %s", hex(42)) -73 | log(logging.INFO, "Hex: %s", hex(255)) +69 | info("Hex: %s", hex(42)) +70 | log(logging.INFO, "Hex: %s", hex(255)) | ^^^^^^^^ -74 | -75 | info("Bytes: %b", bytes("Hello", "utf-8")) - | - -RUF065 Unnecessary `bytes()` conversion when formatting with `%b` - --> RUF065.py:75:19 - | -73 | log(logging.INFO, "Hex: %s", hex(255)) -74 | -75 | info("Bytes: %b", bytes("Hello", "utf-8")) - | ^^^^^^^^^^^^^^^^^^^^^^^ -76 | log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) - | - -RUF065 Unnecessary `bytes()` conversion when formatting with `%b` - --> RUF065.py:76:32 - | -75 | info("Bytes: %b", bytes("Hello", "utf-8")) -76 | log(logging.INFO, "Bytes: %b", bytes("test", "utf-8")) - | ^^^^^^^^^^^^^^^^^^^^^^ |