diff --git a/README.md b/README.md index 418970c42a..3c4a5cae6b 100644 --- a/README.md +++ b/README.md @@ -3778,7 +3778,7 @@ convention = "google" Constant types to ignore when used as "magic values" (see: `PLR2004`). -**Default value**: `["str"]` +**Default value**: `["str", "bytes"]` **Type**: `Vec` diff --git a/resources/test/fixtures/pylint/magic_value_comparison.py b/resources/test/fixtures/pylint/magic_value_comparison.py index 85e0b2a0ea..122887388d 100644 --- a/resources/test/fixtures/pylint/magic_value_comparison.py +++ b/resources/test/fixtures/pylint/magic_value_comparison.py @@ -47,7 +47,7 @@ if input_password == "": # correct if input_password == ADMIN_PASSWORD: # correct pass -if input_password == "Hunter2": # [magic-value-comparison] +if input_password == "Hunter2": # correct pass PI = 3.141592653589793238 @@ -62,7 +62,7 @@ if pi_estimation == PI: # correct HELLO_WORLD = b"Hello, World!" user_input = b"Hello, There!" -if user_input == b"something": # [magic-value-comparison] +if user_input == b"something": # correct pass if user_input == HELLO_WORLD: # correct diff --git a/src/rules/pylint/settings.rs b/src/rules/pylint/settings.rs index 16c1280c65..9d91d3946e 100644 --- a/src/rules/pylint/settings.rs +++ b/src/rules/pylint/settings.rs @@ -45,7 +45,7 @@ impl TryFrom<&Constant> for ConstantType { )] pub struct Options { #[option( - default = r#"["str"]"#, + default = r#"["str", "bytes"]"#, value_type = "Vec", example = r#" allow-magic-value-types = ["int"] @@ -67,7 +67,7 @@ pub struct Settings { impl Default for Settings { fn default() -> Self { Self { - allow_magic_value_types: vec![ConstantType::Str], + allow_magic_value_types: vec![ConstantType::Str, ConstantType::Bytes], max_args: 5, } } diff --git a/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap b/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap index 76d3539aa6..0e1ee6cb3f 100644 --- a/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap +++ b/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap @@ -35,15 +35,4 @@ expression: diagnostics column: 40 fix: ~ parent: ~ -- kind: - MagicValueComparison: - value: "b'something'" - location: - row: 65 - column: 17 - end_location: - row: 65 - column: 29 - fix: ~ - parent: ~