diff --git a/crates/ruff_linter/src/codes.rs b/crates/ruff_linter/src/codes.rs index 00fbc2d6a5b5e..66d6605d21142 100644 --- a/crates/ruff_linter/src/codes.rs +++ b/crates/ruff_linter/src/codes.rs @@ -311,11 +311,11 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Async, "102") => (RuleGroup::Stable, rules::flake8_async::rules::BlockingOsCallInAsyncFunction), // flake8-trio - (Flake8Trio, "100") => (RuleGroup::Preview, rules::flake8_trio::rules::TrioTimeoutWithoutAwait), - (Flake8Trio, "105") => (RuleGroup::Preview, rules::flake8_trio::rules::TrioSyncCall), - (Flake8Trio, "109") => (RuleGroup::Preview, rules::flake8_trio::rules::TrioAsyncFunctionWithTimeout), - (Flake8Trio, "110") => (RuleGroup::Preview, rules::flake8_trio::rules::TrioUnneededSleep), - (Flake8Trio, "115") => (RuleGroup::Preview, rules::flake8_trio::rules::TrioZeroSleepCall), + (Flake8Trio, "100") => (RuleGroup::Stable, rules::flake8_trio::rules::TrioTimeoutWithoutAwait), + (Flake8Trio, "105") => (RuleGroup::Stable, rules::flake8_trio::rules::TrioSyncCall), + (Flake8Trio, "109") => (RuleGroup::Stable, rules::flake8_trio::rules::TrioAsyncFunctionWithTimeout), + (Flake8Trio, "110") => (RuleGroup::Stable, rules::flake8_trio::rules::TrioUnneededSleep), + (Flake8Trio, "115") => (RuleGroup::Stable, rules::flake8_trio::rules::TrioZeroSleepCall), // flake8-builtins (Flake8Builtins, "001") => (RuleGroup::Stable, rules::flake8_builtins::rules::BuiltinVariableShadowing), @@ -423,7 +423,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Quotes, "001") => (RuleGroup::Stable, rules::flake8_quotes::rules::BadQuotesMultilineString), (Flake8Quotes, "002") => (RuleGroup::Stable, rules::flake8_quotes::rules::BadQuotesDocstring), (Flake8Quotes, "003") => (RuleGroup::Stable, rules::flake8_quotes::rules::AvoidableEscapedQuote), - (Flake8Quotes, "004") => (RuleGroup::Preview, rules::flake8_quotes::rules::UnnecessaryEscapedQuote), + (Flake8Quotes, "004") => (RuleGroup::Stable, rules::flake8_quotes::rules::UnnecessaryEscapedQuote), // flake8-annotations (Flake8Annotations, "001") => (RuleGroup::Stable, rules::flake8_annotations::rules::MissingTypeFunctionArgument), @@ -464,7 +464,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Simplify, "109") => (RuleGroup::Stable, rules::flake8_simplify::rules::CompareWithTuple), (Flake8Simplify, "110") => (RuleGroup::Stable, rules::flake8_simplify::rules::ReimplementedBuiltin), (Flake8Simplify, "112") => (RuleGroup::Stable, rules::flake8_simplify::rules::UncapitalizedEnvironmentVariables), - (Flake8Simplify, "113") => (RuleGroup::Preview, rules::flake8_simplify::rules::EnumerateForLoop), + (Flake8Simplify, "113") => (RuleGroup::Stable, rules::flake8_simplify::rules::EnumerateForLoop), (Flake8Simplify, "114") => (RuleGroup::Stable, rules::flake8_simplify::rules::IfWithSameArms), (Flake8Simplify, "115") => (RuleGroup::Stable, rules::flake8_simplify::rules::OpenFileWithContextHandler), (Flake8Simplify, "116") => (RuleGroup::Stable, rules::flake8_simplify::rules::IfElseBlockInsteadOfDictLookup), @@ -483,7 +483,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Simplify, "300") => (RuleGroup::Stable, rules::flake8_simplify::rules::YodaConditions), (Flake8Simplify, "401") => (RuleGroup::Stable, rules::flake8_simplify::rules::IfElseBlockInsteadOfDictGet), (Flake8Simplify, "910") => (RuleGroup::Stable, rules::flake8_simplify::rules::DictGetWithNoneDefault), - (Flake8Simplify, "911") => (RuleGroup::Preview, rules::flake8_simplify::rules::ZipDictKeysAndValues), + (Flake8Simplify, "911") => (RuleGroup::Stable, rules::flake8_simplify::rules::ZipDictKeysAndValues), // flake8-copyright #[allow(deprecated)] @@ -528,7 +528,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Pyupgrade, "038") => (RuleGroup::Stable, rules::pyupgrade::rules::NonPEP604Isinstance), (Pyupgrade, "039") => (RuleGroup::Stable, rules::pyupgrade::rules::UnnecessaryClassParentheses), (Pyupgrade, "040") => (RuleGroup::Stable, rules::pyupgrade::rules::NonPEP695TypeAlias), - (Pyupgrade, "041") => (RuleGroup::Preview, rules::pyupgrade::rules::TimeoutErrorAlias), + (Pyupgrade, "041") => (RuleGroup::Stable, rules::pyupgrade::rules::TimeoutErrorAlias), // pydocstyle (Pydocstyle, "100") => (RuleGroup::Stable, rules::pydocstyle::rules::UndocumentedPublicModule), @@ -615,8 +615,8 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Bandit, "110") => (RuleGroup::Stable, rules::flake8_bandit::rules::TryExceptPass), (Flake8Bandit, "112") => (RuleGroup::Stable, rules::flake8_bandit::rules::TryExceptContinue), (Flake8Bandit, "113") => (RuleGroup::Stable, rules::flake8_bandit::rules::RequestWithoutTimeout), - (Flake8Bandit, "201") => (RuleGroup::Preview, rules::flake8_bandit::rules::FlaskDebugTrue), - (Flake8Bandit, "202") => (RuleGroup::Preview, rules::flake8_bandit::rules::TarfileUnsafeMembers), + (Flake8Bandit, "201") => (RuleGroup::Stable, rules::flake8_bandit::rules::FlaskDebugTrue), + (Flake8Bandit, "202") => (RuleGroup::Stable, rules::flake8_bandit::rules::TarfileUnsafeMembers), (Flake8Bandit, "301") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousPickleUsage), (Flake8Bandit, "302") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousMarshalUsage), (Flake8Bandit, "303") => (RuleGroup::Stable, rules::flake8_bandit::rules::SuspiciousInsecureHashUsage), @@ -654,12 +654,12 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Bandit, "413") => (RuleGroup::Preview, rules::flake8_bandit::rules::SuspiciousPycryptoImport), (Flake8Bandit, "415") => (RuleGroup::Preview, rules::flake8_bandit::rules::SuspiciousPyghmiImport), (Flake8Bandit, "501") => (RuleGroup::Stable, rules::flake8_bandit::rules::RequestWithNoCertValidation), - (Flake8Bandit, "502") => (RuleGroup::Preview, rules::flake8_bandit::rules::SslInsecureVersion), - (Flake8Bandit, "503") => (RuleGroup::Preview, rules::flake8_bandit::rules::SslWithBadDefaults), - (Flake8Bandit, "504") => (RuleGroup::Preview, rules::flake8_bandit::rules::SslWithNoVersion), - (Flake8Bandit, "505") => (RuleGroup::Preview, rules::flake8_bandit::rules::WeakCryptographicKey), + (Flake8Bandit, "502") => (RuleGroup::Stable, rules::flake8_bandit::rules::SslInsecureVersion), + (Flake8Bandit, "503") => (RuleGroup::Stable, rules::flake8_bandit::rules::SslWithBadDefaults), + (Flake8Bandit, "504") => (RuleGroup::Stable, rules::flake8_bandit::rules::SslWithNoVersion), + (Flake8Bandit, "505") => (RuleGroup::Stable, rules::flake8_bandit::rules::WeakCryptographicKey), (Flake8Bandit, "506") => (RuleGroup::Stable, rules::flake8_bandit::rules::UnsafeYAMLLoad), - (Flake8Bandit, "507") => (RuleGroup::Preview, rules::flake8_bandit::rules::SSHNoHostKeyVerification), + (Flake8Bandit, "507") => (RuleGroup::Stable, rules::flake8_bandit::rules::SSHNoHostKeyVerification), (Flake8Bandit, "508") => (RuleGroup::Stable, rules::flake8_bandit::rules::SnmpInsecureVersion), (Flake8Bandit, "509") => (RuleGroup::Stable, rules::flake8_bandit::rules::SnmpWeakCryptography), (Flake8Bandit, "601") => (RuleGroup::Stable, rules::flake8_bandit::rules::ParamikoCall), @@ -671,10 +671,10 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Bandit, "607") => (RuleGroup::Stable, rules::flake8_bandit::rules::StartProcessWithPartialPath), (Flake8Bandit, "608") => (RuleGroup::Stable, rules::flake8_bandit::rules::HardcodedSQLExpression), (Flake8Bandit, "609") => (RuleGroup::Stable, rules::flake8_bandit::rules::UnixCommandWildcardInjection), - (Flake8Bandit, "611") => (RuleGroup::Preview, rules::flake8_bandit::rules::DjangoRawSql), + (Flake8Bandit, "611") => (RuleGroup::Stable, rules::flake8_bandit::rules::DjangoRawSql), (Flake8Bandit, "612") => (RuleGroup::Stable, rules::flake8_bandit::rules::LoggingConfigInsecureListen), (Flake8Bandit, "701") => (RuleGroup::Stable, rules::flake8_bandit::rules::Jinja2AutoescapeFalse), - (Flake8Bandit, "702") => (RuleGroup::Preview, rules::flake8_bandit::rules::MakoTemplates), + (Flake8Bandit, "702") => (RuleGroup::Stable, rules::flake8_bandit::rules::MakoTemplates), // flake8-boolean-trap (Flake8BooleanTrap, "001") => (RuleGroup::Stable, rules::flake8_boolean_trap::rules::BooleanTypeHintPositionalArgument), @@ -779,7 +779,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8Pyi, "053") => (RuleGroup::Stable, rules::flake8_pyi::rules::StringOrBytesTooLong), (Flake8Pyi, "055") => (RuleGroup::Stable, rules::flake8_pyi::rules::UnnecessaryTypeUnion), (Flake8Pyi, "056") => (RuleGroup::Stable, rules::flake8_pyi::rules::UnsupportedMethodCallOnAll), - (Flake8Pyi, "058") => (RuleGroup::Preview, rules::flake8_pyi::rules::GeneratorReturnFromIterMethod), + (Flake8Pyi, "058") => (RuleGroup::Stable, rules::flake8_pyi::rules::GeneratorReturnFromIterMethod), // flake8-pytest-style (Flake8PytestStyle, "001") => (RuleGroup::Stable, rules::flake8_pytest_style::rules::PytestFixtureIncorrectParenthesesStyle), @@ -841,7 +841,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Flake8TypeChecking, "003") => (RuleGroup::Stable, rules::flake8_type_checking::rules::TypingOnlyStandardLibraryImport), (Flake8TypeChecking, "004") => (RuleGroup::Stable, rules::flake8_type_checking::rules::RuntimeImportInTypeCheckingBlock), (Flake8TypeChecking, "005") => (RuleGroup::Stable, rules::flake8_type_checking::rules::EmptyTypeCheckingBlock), - (Flake8TypeChecking, "006") => (RuleGroup::Preview, rules::flake8_type_checking::rules::RuntimeStringUnion), + (Flake8TypeChecking, "006") => (RuleGroup::Stable, rules::flake8_type_checking::rules::RuntimeStringUnion), // tryceratops (Tryceratops, "002") => (RuleGroup::Stable, rules::tryceratops::rules::RaiseVanillaClass), @@ -910,7 +910,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Numpy, "001") => (RuleGroup::Stable, rules::numpy::rules::NumpyDeprecatedTypeAlias), (Numpy, "002") => (RuleGroup::Stable, rules::numpy::rules::NumpyLegacyRandom), (Numpy, "003") => (RuleGroup::Stable, rules::numpy::rules::NumpyDeprecatedFunction), - (Numpy, "201") => (RuleGroup::Preview, rules::numpy::rules::Numpy2Deprecation), + (Numpy, "201") => (RuleGroup::Stable, rules::numpy::rules::Numpy2Deprecation), // ruff (Ruff, "001") => (RuleGroup::Stable, rules::ruff::rules::AmbiguousUnicodeCharacterString), @@ -926,11 +926,10 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Ruff, "013") => (RuleGroup::Stable, rules::ruff::rules::ImplicitOptional), (Ruff, "015") => (RuleGroup::Stable, rules::ruff::rules::UnnecessaryIterableAllocationForFirstElement), (Ruff, "016") => (RuleGroup::Stable, rules::ruff::rules::InvalidIndexType), - #[allow(deprecated)] - (Ruff, "017") => (RuleGroup::Nursery, rules::ruff::rules::QuadraticListSummation), - (Ruff, "018") => (RuleGroup::Preview, rules::ruff::rules::AssignmentInAssert), - (Ruff, "019") => (RuleGroup::Preview, rules::ruff::rules::UnnecessaryKeyCheck), - (Ruff, "020") => (RuleGroup::Preview, rules::ruff::rules::NeverUnion), + (Ruff, "017") => (RuleGroup::Stable, rules::ruff::rules::QuadraticListSummation), + (Ruff, "018") => (RuleGroup::Stable, rules::ruff::rules::AssignmentInAssert), + (Ruff, "019") => (RuleGroup::Stable, rules::ruff::rules::UnnecessaryKeyCheck), + (Ruff, "020") => (RuleGroup::Stable, rules::ruff::rules::NeverUnion), (Ruff, "021") => (RuleGroup::Preview, rules::ruff::rules::ParenthesizeChainedOperators), (Ruff, "022") => (RuleGroup::Preview, rules::ruff::rules::UnsortedDunderAll), (Ruff, "023") => (RuleGroup::Preview, rules::ruff::rules::UnsortedDunderSlots), @@ -1009,10 +1008,10 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> { (Refurb, "181") => (RuleGroup::Preview, rules::refurb::rules::HashlibDigestHex), // flake8-logging - (Flake8Logging, "001") => (RuleGroup::Preview, rules::flake8_logging::rules::DirectLoggerInstantiation), - (Flake8Logging, "002") => (RuleGroup::Preview, rules::flake8_logging::rules::InvalidGetLoggerArgument), - (Flake8Logging, "007") => (RuleGroup::Preview, rules::flake8_logging::rules::ExceptionWithoutExcInfo), - (Flake8Logging, "009") => (RuleGroup::Preview, rules::flake8_logging::rules::UndocumentedWarn), + (Flake8Logging, "001") => (RuleGroup::Stable, rules::flake8_logging::rules::DirectLoggerInstantiation), + (Flake8Logging, "002") => (RuleGroup::Stable, rules::flake8_logging::rules::InvalidGetLoggerArgument), + (Flake8Logging, "007") => (RuleGroup::Stable, rules::flake8_logging::rules::ExceptionWithoutExcInfo), + (Flake8Logging, "009") => (RuleGroup::Stable, rules::flake8_logging::rules::UndocumentedWarn), _ => return None, }) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM114_SIM114.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM114_SIM114.py.snap deleted file mode 100644 index eaf2057160b39..0000000000000 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM114_SIM114.py.snap +++ /dev/null @@ -1,467 +0,0 @@ ---- -source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs ---- -SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -1 | # Errors -2 | / if a: -3 | | b -4 | | elif c: -5 | | b - | |_____^ SIM114 -6 | -7 | if a: # we preserve comments, too! - | - = help: Combine `if` branches - -ℹ Safe fix -1 1 | # Errors -2 |-if a: -3 |- b -4 |-elif c: - 2 |+if a or c: -5 3 | b -6 4 | -7 5 | if a: # we preserve comments, too! - -SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator - | - 5 | b - 6 | - 7 | / if a: # we preserve comments, too! - 8 | | b - 9 | | elif c: # but not on the second branch -10 | | b - | |_____^ SIM114 -11 | -12 | if x == 1: - | - = help: Combine `if` branches - -ℹ Safe fix -4 4 | elif c: -5 5 | b -6 6 | -7 |-if a: # we preserve comments, too! -8 |- b -9 |-elif c: # but not on the second branch - 7 |+if a or c: # we preserve comments, too! -10 8 | b -11 9 | -12 10 | if x == 1: - -SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -10 | b -11 | -12 | / if x == 1: -13 | | for _ in range(20): -14 | | print("hello") -15 | | elif x == 2: -16 | | for _ in range(20): -17 | | print("hello") - | |______________________^ SIM114 -18 | -19 | if x == 1: - | - = help: Combine `if` branches - -ℹ Safe fix -9 9 | elif c: # but not on the second branch -10 10 | b -11 11 | -12 |-if x == 1: -13 |- for _ in range(20): -14 |- print("hello") -15 |-elif x == 2: - 12 |+if x == 1 or x == 2: -16 13 | for _ in range(20): -17 14 | print("hello") -18 15 | - -SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -17 | print("hello") -18 | -19 | / if x == 1: -20 | | if True: -21 | | for _ in range(20): -22 | | print("hello") -23 | | elif x == 2: -24 | | if True: -25 | | for _ in range(20): -26 | | print("hello") - | |__________________________^ SIM114 -27 | -28 | if x == 1: - | - = help: Combine `if` branches - -ℹ Safe fix -16 16 | for _ in range(20): -17 17 | print("hello") -18 18 | -19 |-if x == 1: -20 |- if True: -21 |- for _ in range(20): -22 |- print("hello") -23 |-elif x == 2: - 19 |+if x == 1 or x == 2: -24 20 | if True: -25 21 | for _ in range(20): -26 22 | print("hello") - -SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -26 | print("hello") -27 | -28 | / if x == 1: -29 | | if True: -30 | | for _ in range(20): -31 | | print("hello") -32 | | elif False: -33 | | for _ in range(20): -34 | | print("hello") -35 | | elif x == 2: -36 | | if True: -37 | | for _ in range(20): -38 | | print("hello") -39 | | elif False: -40 | | for _ in range(20): -41 | | print("hello") - | |__________________________^ SIM114 -42 | -43 | if ( - | - = help: Combine `if` branches - -ℹ Safe fix -25 25 | for _ in range(20): -26 26 | print("hello") -27 27 | -28 |-if x == 1: -29 |- if True: -30 |- for _ in range(20): -31 |- print("hello") -32 |- elif False: -33 |- for _ in range(20): -34 |- print("hello") -35 |-elif x == 2: - 28 |+if x == 1 or x == 2: -36 29 | if True: -37 30 | for _ in range(20): -38 31 | print("hello") - -SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator - | -28 | if x == 1: -29 | if True: - | _____^ -30 | | for _ in range(20): -31 | | print("hello") -32 | | elif False: -33 | | for _ in range(20): -34 | | print("hello") - | |__________________________^ SIM114 -35 | elif x == 2: -36 | if True: - | - = help: Combine `if` branches - -ℹ Safe fix -26 26 | print("hello") -27 27 | -28 28 | if x == 1: -29 |- if True: -30 |- for _ in range(20): -31 |- print("hello") -32 |- elif False: - 29 |+ if True or False: -33 30 | for _ in range(20): -34 31 | print("hello") -35 32 | elif x == 2: - -SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator - | -34 | print("hello") -35 | elif x == 2: -36 | if True: - | _____^ -37 | | for _ in range(20): -38 | | print("hello") -39 | | elif False: -40 | | for _ in range(20): -41 | | print("hello") - | |__________________________^ SIM114 -42 | -43 | if ( - | - = help: Combine `if` branches - -ℹ Safe fix -33 33 | for _ in range(20): -34 34 | print("hello") -35 35 | elif x == 2: -36 |- if True: -37 |- for _ in range(20): -38 |- print("hello") -39 |- elif False: - 36 |+ if True or False: -40 37 | for _ in range(20): -41 38 | print("hello") -42 39 | - -SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -41 | print("hello") -42 | -43 | / if ( -44 | | x == 1 -45 | | and y == 2 -46 | | and z == 3 -47 | | and a == 4 -48 | | and b == 5 -49 | | and c == 6 -50 | | and d == 7 -51 | | and e == 8 -52 | | and f == 9 -53 | | and g == 10 -54 | | and h == 11 -55 | | and i == 12 -56 | | and j == 13 -57 | | and k == 14 -58 | | ): -59 | | pass -60 | | elif 1 == 2: -61 | | pass - | |________^ SIM114 -62 | -63 | if result.eofs == "O": - | - = help: Combine `if` branches - -ℹ Safe fix -55 55 | and i == 12 -56 56 | and j == 13 -57 57 | and k == 14 -58 |-): -59 |- pass -60 |-elif 1 == 2: - 58 |+) or 1 == 2: -61 59 | pass -62 60 | -63 61 | if result.eofs == "O": - -SIM114.py:67:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -65 | elif result.eofs == "S": -66 | skipped = 1 -67 | / elif result.eofs == "F": -68 | | errors = 1 -69 | | elif result.eofs == "E": -70 | | errors = 1 - | |______________^ SIM114 -71 | elif result.eofs == "X": -72 | errors = 1 - | - = help: Combine `if` branches - -ℹ Safe fix -64 64 | pass -65 65 | elif result.eofs == "S": -66 66 | skipped = 1 -67 |-elif result.eofs == "F": -68 |- errors = 1 -69 |-elif result.eofs == "E": - 67 |+elif result.eofs == "F" or result.eofs == "E": -70 68 | errors = 1 -71 69 | elif result.eofs == "X": -72 70 | errors = 1 - -SIM114.py:69:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -67 | elif result.eofs == "F": -68 | errors = 1 -69 | / elif result.eofs == "E": -70 | | errors = 1 -71 | | elif result.eofs == "X": -72 | | errors = 1 - | |______________^ SIM114 -73 | elif result.eofs == "C": -74 | errors = 1 - | - = help: Combine `if` branches - -ℹ Safe fix -66 66 | skipped = 1 -67 67 | elif result.eofs == "F": -68 68 | errors = 1 -69 |-elif result.eofs == "E": -70 |- errors = 1 -71 |-elif result.eofs == "X": - 69 |+elif result.eofs == "E" or result.eofs == "X": -72 70 | errors = 1 -73 71 | elif result.eofs == "C": -74 72 | errors = 1 - -SIM114.py:71:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -69 | elif result.eofs == "E": -70 | errors = 1 -71 | / elif result.eofs == "X": -72 | | errors = 1 -73 | | elif result.eofs == "C": -74 | | errors = 1 - | |______________^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -68 68 | errors = 1 -69 69 | elif result.eofs == "E": -70 70 | errors = 1 -71 |-elif result.eofs == "X": -72 |- errors = 1 -73 |-elif result.eofs == "C": - 71 |+elif result.eofs == "X" or result.eofs == "C": -74 72 | errors = 1 -75 73 | -76 74 | - -SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator - | -116 | a = True -117 | b = False -118 | if a > b: # end-of-line - | _____^ -119 | | return 3 -120 | | elif a == b: -121 | | return 3 - | |________________^ SIM114 -122 | elif a < b: # end-of-line -123 | return 4 - | - = help: Combine `if` branches - -ℹ Safe fix -115 115 | def func(): -116 116 | a = True -117 117 | b = False -118 |- if a > b: # end-of-line -119 |- return 3 -120 |- elif a == b: - 118 |+ if a > b or a == b: # end-of-line -121 119 | return 3 -122 120 | elif a < b: # end-of-line -123 121 | return 4 - -SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator - | -120 | elif a == b: -121 | return 3 -122 | elif a < b: # end-of-line - | _____^ -123 | | return 4 -124 | | elif b is None: -125 | | return 4 - | |________________^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -119 119 | return 3 -120 120 | elif a == b: -121 121 | return 3 -122 |- elif a < b: # end-of-line -123 |- return 4 -124 |- elif b is None: - 122 |+ elif a < b or b is None: # end-of-line -125 123 | return 4 -126 124 | -127 125 | - -SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator - | -130 | a = True -131 | b = False -132 | if a > b: # end-of-line - | _____^ -133 | | return 3 -134 | | elif a := 1: -135 | | return 3 - | |________________^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -129 129 | """Ensure that the named expression is parenthesized when merged.""" -130 130 | a = True -131 131 | b = False -132 |- if a > b: # end-of-line -133 |- return 3 -134 |- elif a := 1: - 132 |+ if a > b or (a := 1): # end-of-line -135 133 | return 3 -136 134 | -137 135 | - -SIM114.py:138:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -138 | / if a: # we preserve comments, too! -139 | | b -140 | | elif c: # but not on the second branch -141 | | b - | |_____^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -135 135 | return 3 -136 136 | -137 137 | -138 |-if a: # we preserve comments, too! -139 |- b -140 |-elif c: # but not on the second branch - 138 |+if a or c: # we preserve comments, too! -141 139 | b -142 140 | -143 141 | - -SIM114.py:144:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -144 | / if a: b # here's a comment -145 | | elif c: b - | |_________^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -141 141 | b -142 142 | -143 143 | -144 |-if a: b # here's a comment -145 |-elif c: b - 144 |+if a or c: b # here's a comment -146 145 | -147 146 | -148 147 | if(x > 200): pass - -SIM114.py:148:1: SIM114 [*] Combine `if` branches using logical `or` operator - | -148 | / if(x > 200): pass -149 | | elif(100 < x and x < 200 and 300 < y and y < 800): -150 | | pass - | |________^ SIM114 - | - = help: Combine `if` branches - -ℹ Safe fix -145 145 | elif c: b -146 146 | -147 147 | -148 |-if(x > 200): pass -149 |-elif(100 < x and x < 200 and 300 < y and y < 800): -150 |- pass - 148 |+if(x > 200) or (100 < x and x < 200 and 300 < y and y < 800): pass - - diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index 4b51bf2c7a197..47079922eef43 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -1454,9 +1454,6 @@ mod tests { use std::str::FromStr; const PREVIEW_RULES: &[Rule] = &[ - Rule::AssignmentInAssert, - Rule::DirectLoggerInstantiation, - Rule::InvalidGetLoggerArgument, Rule::IsinstanceTypeNone, Rule::IfExprMinMax, Rule::ManualDictComprehension, @@ -1464,7 +1461,6 @@ mod tests { Rule::SliceCopy, Rule::TooManyPublicMethods, Rule::TooManyPublicMethods, - Rule::UndocumentedWarn, Rule::UnnecessaryEnumerate, Rule::MathConstant, ];