From 7c22fc8249a7b8a34f2ac8fbb0a4c5993ef58e68 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 1 Aug 2025 19:27:42 -0400 Subject: [PATCH 1/7] fix-19610 --- .../test/fixtures/flake8_simplify/SIM905.py | 8 ++- .../rules/split_static_string.rs | 47 ++++++++++++- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 66 +++++++++++++++++++ 3 files changed, 118 insertions(+), 3 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py index 049b60dfaf..381bf03f8c 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py @@ -129,4 +129,10 @@ print(" x ".rsplit(maxsplit=0)) print(" x ".rsplit(maxsplit=0)) print(" x ".rsplit(sep=None, maxsplit=0)) print(" x ".rsplit(maxsplit=0)) -print(" x ".rsplit(sep=None, maxsplit=0)) \ No newline at end of file +print(" x ".rsplit(sep=None, maxsplit=0)) + +# https://github.com/astral-sh/ruff/issues/19610 +r"1" "\n".split("1") # [r"", "\n"] +r"" "\"".split("1") # ['"'] +r"1" """ +""".split("1") # [r"", "\n"] diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs index c298e82f05..6a6a0a8869 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs @@ -1,9 +1,12 @@ use std::cmp::Ordering; use ruff_macros::{ViolationMetadata, derive_message_formats}; +use ruff_python_ast::StringFlags; +use ruff_python_ast::str::TripleQuotes; +use ruff_python_ast::str_prefix::StringLiteralPrefix; use ruff_python_ast::{ Expr, ExprCall, ExprContext, ExprList, ExprUnaryOp, StringLiteral, StringLiteralFlags, - StringLiteralValue, UnaryOp, str::TripleQuotes, + StringLiteralValue, UnaryOp, }; use ruff_text_size::{Ranged, TextRange}; @@ -116,11 +119,40 @@ pub(crate) fn split_static_string( } } +/// Check if a string contains characters that would be unescapable in an r-string. +/// +/// In r-strings, backslashes are treated literally, so sequences like `\n`, `\t`, etc. +/// are not valid escape sequences and will cause syntax errors. +/// This function now checks for all cases where a string cannot be safely represented as a raw string. +fn contains_unescapable_for_rstring(s: &str, quote: char, triple_quoted: bool) -> bool { + if s.ends_with('\\') { + return true; + } + if s.contains(quote) { + if triple_quoted { + let triple = std::iter::repeat_n(quote, 3).collect::(); + if s.contains(&triple) { + return true; + } + } else { + return true; + } + } + if !triple_quoted && s.contains('\n') { + return true; + } + false +} + fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { + let quote = flags.quote_style().as_char(); + let triple_quoted = flags.triple_quotes() == TripleQuotes::Yes; Expr::List(ExprList { elts: elts .iter() .map(|elt| { + let should_use_r_string = matches!(flags.prefix(), StringLiteralPrefix::Raw { .. }) + && !contains_unescapable_for_rstring(elt, quote, triple_quoted); Expr::from(StringLiteral { value: Box::from(*elt), range: TextRange::default(), @@ -135,7 +167,18 @@ fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { // itemC // """.split() # -> ["""itemA""", """itemB""", """itemC"""] // ``` - flags: flags.with_triple_quotes(TripleQuotes::No), + flags: if should_use_r_string { + flags.with_triple_quotes(TripleQuotes::No) + } else { + let new_prefix = match flags.prefix() { + StringLiteralPrefix::Raw { .. } => StringLiteralPrefix::Empty, + StringLiteralPrefix::Unicode => StringLiteralPrefix::Unicode, + StringLiteralPrefix::Empty => StringLiteralPrefix::Empty, + }; + flags + .with_triple_quotes(TripleQuotes::No) + .with_prefix(new_prefix) + }, }) }) .collect(), diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap index ae93115007..2e6a063dfd 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -1226,6 +1226,7 @@ SIM905.py:130:7: SIM905 [*] Consider using a list literal instead of `str.split` 130 |+print([" x"]) 131 131 | print(" x ".rsplit(maxsplit=0)) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | SIM905.py:131:7: SIM905 [*] Consider using a list literal instead of `str.split` | @@ -1244,6 +1245,8 @@ SIM905.py:131:7: SIM905 [*] Consider using a list literal instead of `str.split` 131 |-print(" x ".rsplit(maxsplit=0)) 131 |+print([" x"]) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` | @@ -1251,6 +1254,8 @@ SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` 131 | print(" x ".rsplit(maxsplit=0)) 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +133 | +134 | # https://github.com/astral-sh/ruff/issues/19610 | = help: Replace with list literal @@ -1260,3 +1265,64 @@ SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` 131 131 | print(" x ".rsplit(maxsplit=0)) 132 |-print(" x ".rsplit(sep=None, maxsplit=0)) 132 |+print([" x"]) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] + +SIM905.py:135:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ SIM905 +136 | r"" "\"".split("1") # ['"'] +137 | r"1" """ + | + = help: Replace with list literal + +ℹ Safe fix +132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 |-r"1" "\n".split("1") # [r"", "\n"] + 135 |+[r"", "\n"] # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] + +SIM905.py:136:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ SIM905 +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] + | + = help: Replace with list literal + +ℹ Safe fix +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 |-r"" "\"".split("1") # ['"'] + 136 |+['"'] # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] + +SIM905.py:137:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] +137 | / r"1" """ +138 | | """.split("1") # [r"", "\n"] + | |______________^ SIM905 + | + = help: Replace with list literal + +ℹ Safe fix +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 |-r"1" """ +138 |-""".split("1") # [r"", "\n"] + 137 |+[r"", "\n"] # [r"", "\n"] From ec42d31e2b2eeb819e5b8372b0148a0b6d668532 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 1 Aug 2025 20:29:40 -0400 Subject: [PATCH 2/7] add case --- .../test/fixtures/flake8_simplify/SIM905.py | 1 + ...ke8_simplify__tests__SIM905_SIM905.py.snap | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py index 381bf03f8c..365e6dce3a 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py @@ -136,3 +136,4 @@ r"1" "\n".split("1") # [r"", "\n"] r"" "\"".split("1") # ['"'] r"1" """ """.split("1") # [r"", "\n"] +r"\n" "\n'\"".split("1") # ["\\n\n'\""] diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap index 2e6a063dfd..694422c4ac 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -1308,6 +1308,7 @@ SIM905.py:136:1: SIM905 [*] Consider using a list literal instead of `str.split` 136 |+['"'] # ['"'] 137 137 | r"1" """ 138 138 | """.split("1") # [r"", "\n"] +139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] SIM905.py:137:1: SIM905 [*] Consider using a list literal instead of `str.split` | @@ -1316,6 +1317,7 @@ SIM905.py:137:1: SIM905 [*] Consider using a list literal instead of `str.split` 137 | / r"1" """ 138 | | """.split("1") # [r"", "\n"] | |______________^ SIM905 +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] | = help: Replace with list literal @@ -1326,3 +1328,20 @@ SIM905.py:137:1: SIM905 [*] Consider using a list literal instead of `str.split` 137 |-r"1" """ 138 |-""".split("1") # [r"", "\n"] 137 |+[r"", "\n"] # [r"", "\n"] +139 138 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905.py:139:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | + = help: Replace with list literal + +ℹ Safe fix +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] +139 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] + 139 |+["\\n\n'\""] # ["\\n\n'\""] From a3ea8a995b0c5b9cf7092ad13eef3b7cae374652 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 4 Aug 2025 19:09:54 -0400 Subject: [PATCH 3/7] Update split_static_string.rs --- .../src/rules/flake8_simplify/rules/split_static_string.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs index 1513912ab2..1b00858a14 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs @@ -151,8 +151,6 @@ fn replace_flags(elt: &str, flags: StringLiteralFlags) -> StringLiteralFlags { } fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { - let quote = flags.quote_style().as_char(); - let triple_quoted = flags.triple_quotes() == ruff_python_ast::str::TripleQuotes::Yes; Expr::List(ExprList { elts: elts .iter() From fd53f765c40bb298b2bb42bbea0a8ff6e33c62c6 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 6 Aug 2025 12:33:49 -0400 Subject: [PATCH 4/7] fix syntax --- .../rules/split_static_string.rs | 36 +- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 1436 +++++++++++++++++ 2 files changed, 1456 insertions(+), 16 deletions(-) create mode 100644 crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs index 1b00858a14..929d42a8d2 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs @@ -1,10 +1,9 @@ use std::cmp::Ordering; use ruff_macros::{ViolationMetadata, derive_message_formats}; -use ruff_python_ast::StringFlags; use ruff_python_ast::{ - Expr, ExprCall, ExprContext, ExprList, ExprUnaryOp, StringLiteral, StringLiteralFlags, - StringLiteralValue, UnaryOp, + Expr, ExprCall, ExprContext, ExprList, ExprUnaryOp, StringFlags, StringLiteral, + StringLiteralFlags, StringLiteralValue, UnaryOp, }; use ruff_text_size::{Ranged, TextRange}; @@ -132,22 +131,27 @@ fn replace_flags(elt: &str, flags: StringLiteralFlags) -> StringLiteralFlags { // 'single'quoted // """.split() # -> [r"itemA",r"'single'quoted'"] // ``` - if !flags.prefix().is_raw() || !elt.contains(flags.quote_style().as_char()) { - flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) + + if !flags.prefix().is_raw() { + return flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); } - // If we have a raw string containing a quotation mark of the same style, - // then we have to swap the style of quotation marks used - else if !elt.contains(flags.quote_style().opposite().as_char()) { - flags + + if elt.contains('\n') || elt.contains('\r') { + return StringLiteralFlags::empty() + .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); + } + + if elt.contains(flags.quote_style().as_char()) { + if elt.contains(flags.quote_style().opposite().as_char()) { + return StringLiteralFlags::empty() + .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); + } + return flags .with_quote_style(flags.quote_style().opposite()) - .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) - } else - // If both types of quotes are used in the raw, triple-quoted string, then - // we are forced to either add escapes or keep the triple quotes. We opt for - // the latter. - { - flags + .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); } + + flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) } fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap new file mode 100644 index 0000000000..3be5b8fd37 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -0,0 +1,1436 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM905.py:6:1: SIM905 [*] Consider using a list literal instead of `str.split` + | + 5 | # positives + 6 | / """ + 7 | | itemA + 8 | | itemB + 9 | | itemC +10 | | """.split() + | |___________^ SIM905 +11 | +12 | "a,b,c,d".split(",") + | + = help: Replace with list literal + +ℹ Safe fix +3 3 | no_sep = None +4 4 | +5 5 | # positives +6 |-""" +7 |- itemA +8 |- itemB +9 |- itemC +10 |-""".split() + 6 |+["itemA", "itemB", "itemC"] +11 7 | +12 8 | "a,b,c,d".split(",") +13 9 | "a,b,c,d".split(None) + +SIM905.py:12:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +10 | """.split() +11 | +12 | "a,b,c,d".split(",") + | ^^^^^^^^^^^^^^^^^^^^ SIM905 +13 | "a,b,c,d".split(None) +14 | "a,b,c,d".split(",", 1) + | + = help: Replace with list literal + +ℹ Safe fix +9 9 | itemC +10 10 | """.split() +11 11 | +12 |-"a,b,c,d".split(",") + 12 |+["a", "b", "c", "d"] +13 13 | "a,b,c,d".split(None) +14 14 | "a,b,c,d".split(",", 1) +15 15 | "a,b,c,d".split(None, 1) + +SIM905.py:13:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +12 | "a,b,c,d".split(",") +13 | "a,b,c,d".split(None) + | ^^^^^^^^^^^^^^^^^^^^^ SIM905 +14 | "a,b,c,d".split(",", 1) +15 | "a,b,c,d".split(None, 1) + | + = help: Replace with list literal + +ℹ Safe fix +10 10 | """.split() +11 11 | +12 12 | "a,b,c,d".split(",") +13 |-"a,b,c,d".split(None) + 13 |+["a,b,c,d"] +14 14 | "a,b,c,d".split(",", 1) +15 15 | "a,b,c,d".split(None, 1) +16 16 | "a,b,c,d".split(sep=",") + +SIM905.py:14:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +12 | "a,b,c,d".split(",") +13 | "a,b,c,d".split(None) +14 | "a,b,c,d".split(",", 1) + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +15 | "a,b,c,d".split(None, 1) +16 | "a,b,c,d".split(sep=",") + | + = help: Replace with list literal + +ℹ Safe fix +11 11 | +12 12 | "a,b,c,d".split(",") +13 13 | "a,b,c,d".split(None) +14 |-"a,b,c,d".split(",", 1) + 14 |+["a", "b,c,d"] +15 15 | "a,b,c,d".split(None, 1) +16 16 | "a,b,c,d".split(sep=",") +17 17 | "a,b,c,d".split(sep=None) + +SIM905.py:15:1: SIM905 Consider using a list literal instead of `str.split` + | +13 | "a,b,c,d".split(None) +14 | "a,b,c,d".split(",", 1) +15 | "a,b,c,d".split(None, 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +16 | "a,b,c,d".split(sep=",") +17 | "a,b,c,d".split(sep=None) + | + = help: Replace with list literal + +SIM905.py:16:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +14 | "a,b,c,d".split(",", 1) +15 | "a,b,c,d".split(None, 1) +16 | "a,b,c,d".split(sep=",") + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +17 | "a,b,c,d".split(sep=None) +18 | "a,b,c,d".split(sep=",", maxsplit=1) + | + = help: Replace with list literal + +ℹ Safe fix +13 13 | "a,b,c,d".split(None) +14 14 | "a,b,c,d".split(",", 1) +15 15 | "a,b,c,d".split(None, 1) +16 |-"a,b,c,d".split(sep=",") + 16 |+["a", "b", "c", "d"] +17 17 | "a,b,c,d".split(sep=None) +18 18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 19 | "a,b,c,d".split(sep=None, maxsplit=1) + +SIM905.py:17:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +15 | "a,b,c,d".split(None, 1) +16 | "a,b,c,d".split(sep=",") +17 | "a,b,c,d".split(sep=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 | "a,b,c,d".split(sep=None, maxsplit=1) + | + = help: Replace with list literal + +ℹ Safe fix +14 14 | "a,b,c,d".split(",", 1) +15 15 | "a,b,c,d".split(None, 1) +16 16 | "a,b,c,d".split(sep=",") +17 |-"a,b,c,d".split(sep=None) + 17 |+["a,b,c,d"] +18 18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 20 | "a,b,c,d".split(maxsplit=1, sep=",") + +SIM905.py:18:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +16 | "a,b,c,d".split(sep=",") +17 | "a,b,c,d".split(sep=None) +18 | "a,b,c,d".split(sep=",", maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 | "a,b,c,d".split(maxsplit=1, sep=",") + | + = help: Replace with list literal + +ℹ Safe fix +15 15 | "a,b,c,d".split(None, 1) +16 16 | "a,b,c,d".split(sep=",") +17 17 | "a,b,c,d".split(sep=None) +18 |-"a,b,c,d".split(sep=",", maxsplit=1) + 18 |+["a", "b,c,d"] +19 19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 21 | "a,b,c,d".split(maxsplit=1, sep=None) + +SIM905.py:19:1: SIM905 Consider using a list literal instead of `str.split` + | +17 | "a,b,c,d".split(sep=None) +18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 | "a,b,c,d".split(sep=None, maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 | "a,b,c,d".split(maxsplit=1, sep=None) + | + = help: Replace with list literal + +SIM905.py:20:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 | "a,b,c,d".split(maxsplit=1, sep=",") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 | "a,b,c,d".split(",", maxsplit=1) + | + = help: Replace with list literal + +ℹ Safe fix +17 17 | "a,b,c,d".split(sep=None) +18 18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 |-"a,b,c,d".split(maxsplit=1, sep=",") + 20 |+["a", "b,c,d"] +21 21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 22 | "a,b,c,d".split(",", maxsplit=1) +23 23 | "a,b,c,d".split(None, maxsplit=1) + +SIM905.py:21:1: SIM905 Consider using a list literal instead of `str.split` + | +19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 | "a,b,c,d".split(maxsplit=1, sep=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +22 | "a,b,c,d".split(",", maxsplit=1) +23 | "a,b,c,d".split(None, maxsplit=1) + | + = help: Replace with list literal + +SIM905.py:22:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 | "a,b,c,d".split(",", maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +23 | "a,b,c,d".split(None, maxsplit=1) +24 | "a,b,c,d".split(maxsplit=1) + | + = help: Replace with list literal + +ℹ Safe fix +19 19 | "a,b,c,d".split(sep=None, maxsplit=1) +20 20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 |-"a,b,c,d".split(",", maxsplit=1) + 22 |+["a", "b,c,d"] +23 23 | "a,b,c,d".split(None, maxsplit=1) +24 24 | "a,b,c,d".split(maxsplit=1) +25 25 | "a,b,c,d".split(maxsplit=1.0) + +SIM905.py:23:1: SIM905 Consider using a list literal instead of `str.split` + | +21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 | "a,b,c,d".split(",", maxsplit=1) +23 | "a,b,c,d".split(None, maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +24 | "a,b,c,d".split(maxsplit=1) +25 | "a,b,c,d".split(maxsplit=1.0) + | + = help: Replace with list literal + +SIM905.py:24:1: SIM905 Consider using a list literal instead of `str.split` + | +22 | "a,b,c,d".split(",", maxsplit=1) +23 | "a,b,c,d".split(None, maxsplit=1) +24 | "a,b,c,d".split(maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +25 | "a,b,c,d".split(maxsplit=1.0) +26 | "a,b,c,d".split(maxsplit=1) + | + = help: Replace with list literal + +SIM905.py:26:1: SIM905 Consider using a list literal instead of `str.split` + | +24 | "a,b,c,d".split(maxsplit=1) +25 | "a,b,c,d".split(maxsplit=1.0) +26 | "a,b,c,d".split(maxsplit=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") + | + = help: Replace with list literal + +SIM905.py:27:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +25 | "a,b,c,d".split(maxsplit=1.0) +26 | "a,b,c,d".split(maxsplit=1) +27 | "a,b,c,d".split(maxsplit=0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +28 | "VERB AUX PRON ADP DET".split(" ") +29 | ' 1 2 3 '.split() + | + = help: Replace with list literal + +ℹ Safe fix +24 24 | "a,b,c,d".split(maxsplit=1) +25 25 | "a,b,c,d".split(maxsplit=1.0) +26 26 | "a,b,c,d".split(maxsplit=1) +27 |-"a,b,c,d".split(maxsplit=0) + 27 |+["a,b,c,d"] +28 28 | "VERB AUX PRON ADP DET".split(" ") +29 29 | ' 1 2 3 '.split() +30 30 | '1<>2<>3<4'.split('<>') + +SIM905.py:28:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +26 | "a,b,c,d".split(maxsplit=1) +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +29 | ' 1 2 3 '.split() +30 | '1<>2<>3<4'.split('<>') + | + = help: Replace with list literal + +ℹ Safe fix +25 25 | "a,b,c,d".split(maxsplit=1.0) +26 26 | "a,b,c,d".split(maxsplit=1) +27 27 | "a,b,c,d".split(maxsplit=0) +28 |-"VERB AUX PRON ADP DET".split(" ") + 28 |+["VERB", "AUX", "PRON", "ADP", "DET"] +29 29 | ' 1 2 3 '.split() +30 30 | '1<>2<>3<4'.split('<>') +31 31 | + +SIM905.py:29:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") +29 | ' 1 2 3 '.split() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +30 | '1<>2<>3<4'.split('<>') + | + = help: Replace with list literal + +ℹ Safe fix +26 26 | "a,b,c,d".split(maxsplit=1) +27 27 | "a,b,c,d".split(maxsplit=0) +28 28 | "VERB AUX PRON ADP DET".split(" ") +29 |-' 1 2 3 '.split() + 29 |+['1', '2', '3'] +30 30 | '1<>2<>3<4'.split('<>') +31 31 | +32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] + +SIM905.py:30:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +28 | "VERB AUX PRON ADP DET".split(" ") +29 | ' 1 2 3 '.split() +30 | '1<>2<>3<4'.split('<>') + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +31 | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] + | + = help: Replace with list literal + +ℹ Safe fix +27 27 | "a,b,c,d".split(maxsplit=0) +28 28 | "VERB AUX PRON ADP DET".split(" ") +29 29 | ' 1 2 3 '.split() +30 |-'1<>2<>3<4'.split('<>') + 30 |+['1', '2', '3<4'] +31 31 | +32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 33 | "".split() # [] + +SIM905.py:32:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +30 | '1<>2<>3<4'.split('<>') +31 | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +33 | "".split() # [] +34 | """ + | + = help: Replace with list literal + +ℹ Safe fix +29 29 | ' 1 2 3 '.split() +30 30 | '1<>2<>3<4'.split('<>') +31 31 | +32 |-" a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] + 32 |+[" a", "a a", "a a "] # [" a", "a a", "a a "] +33 33 | "".split() # [] +34 34 | """ +35 35 | """.split() # [] + +SIM905.py:33:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 | "".split() # [] + | ^^^^^^^^^^ SIM905 +34 | """ +35 | """.split() # [] + | + = help: Replace with list literal + +ℹ Safe fix +30 30 | '1<>2<>3<4'.split('<>') +31 31 | +32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 |-"".split() # [] + 33 |+[] # [] +34 34 | """ +35 35 | """.split() # [] +36 36 | " ".split() # [] + +SIM905.py:34:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 | "".split() # [] +34 | / """ +35 | | """.split() # [] + | |___________^ SIM905 +36 | " ".split() # [] +37 | "/abc/".split() # ["/abc/"] + | + = help: Replace with list literal + +ℹ Safe fix +31 31 | +32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 33 | "".split() # [] +34 |-""" +35 |-""".split() # [] + 34 |+[] # [] +36 35 | " ".split() # [] +37 36 | "/abc/".split() # ["/abc/"] +38 37 | ("a,b,c" + +SIM905.py:36:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +34 | """ +35 | """.split() # [] +36 | " ".split() # [] + | ^^^^^^^^^^^^^^^^^ SIM905 +37 | "/abc/".split() # ["/abc/"] +38 | ("a,b,c" + | + = help: Replace with list literal + +ℹ Safe fix +33 33 | "".split() # [] +34 34 | """ +35 35 | """.split() # [] +36 |-" ".split() # [] + 36 |+[] # [] +37 37 | "/abc/".split() # ["/abc/"] +38 38 | ("a,b,c" +39 39 | # comment + +SIM905.py:37:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +35 | """.split() # [] +36 | " ".split() # [] +37 | "/abc/".split() # ["/abc/"] + | ^^^^^^^^^^^^^^^ SIM905 +38 | ("a,b,c" +39 | # comment + | + = help: Replace with list literal + +ℹ Safe fix +34 34 | """ +35 35 | """.split() # [] +36 36 | " ".split() # [] +37 |-"/abc/".split() # ["/abc/"] + 37 |+["/abc/"] # ["/abc/"] +38 38 | ("a,b,c" +39 39 | # comment +40 40 | .split() + +SIM905.py:38:2: SIM905 [*] Consider using a list literal instead of `str.split` + | +36 | " ".split() # [] +37 | "/abc/".split() # ["/abc/"] +38 | ("a,b,c" + | __^ +39 | | # comment +40 | | .split() + | |________^ SIM905 +41 | ) # ["a,b,c"] +42 | ("a,b,c" + | + = help: Replace with list literal + +ℹ Unsafe fix +35 35 | """.split() # [] +36 36 | " ".split() # [] +37 37 | "/abc/".split() # ["/abc/"] +38 |-("a,b,c" +39 |-# comment +40 |-.split() + 38 |+(["a,b,c"] +41 39 | ) # ["a,b,c"] +42 40 | ("a,b,c" +43 41 | # comment1 + +SIM905.py:42:2: SIM905 [*] Consider using a list literal instead of `str.split` + | +40 | .split() +41 | ) # ["a,b,c"] +42 | ("a,b,c" + | __^ +43 | | # comment1 +44 | | .split(",") + | |___________^ SIM905 +45 | ) # ["a", "b", "c"] +46 | ("a," + | + = help: Replace with list literal + +ℹ Unsafe fix +39 39 | # comment +40 40 | .split() +41 41 | ) # ["a,b,c"] +42 |-("a,b,c" +43 |-# comment1 +44 |-.split(",") + 42 |+(["a", "b", "c"] +45 43 | ) # ["a", "b", "c"] +46 44 | ("a," +47 45 | # comment + +SIM905.py:46:2: SIM905 [*] Consider using a list literal instead of `str.split` + | +44 | .split(",") +45 | ) # ["a", "b", "c"] +46 | ("a," + | __^ +47 | | # comment +48 | | "b," +49 | | "c" +50 | | .split(",") + | |___________^ SIM905 +51 | ) # ["a", "b", "c"] + | + = help: Replace with list literal + +ℹ Unsafe fix +43 43 | # comment1 +44 44 | .split(",") +45 45 | ) # ["a", "b", "c"] +46 |-("a," +47 |-# comment +48 |-"b," +49 |-"c" +50 |-.split(",") + 46 |+(["a", "b", "c"] +51 47 | ) # ["a", "b", "c"] +52 48 | +53 49 | "hello "\ + +SIM905.py:53:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +51 | ) # ["a", "b", "c"] +52 | +53 | / "hello "\ +54 | | "world".split() + | |___________________^ SIM905 +55 | # ["hello", "world"] + | + = help: Replace with list literal + +ℹ Safe fix +50 50 | .split(",") +51 51 | ) # ["a", "b", "c"] +52 52 | +53 |-"hello "\ +54 |- "world".split() + 53 |+["hello", "world"] +55 54 | # ["hello", "world"] +56 55 | +57 56 | # prefixes and isc + +SIM905.py:58:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +57 | # prefixes and isc +58 | u"a b".split() # [u"a", u"b"] + | ^^^^^^^^^^^^^^ SIM905 +59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 | ("a " "b").split() # ["a", "b"] + | + = help: Replace with list literal + +ℹ Safe fix +55 55 | # ["hello", "world"] +56 56 | +57 57 | # prefixes and isc +58 |-u"a b".split() # [u"a", u"b"] + 58 |+[u"a", u"b"] # [u"a", u"b"] +59 59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 60 | ("a " "b").split() # ["a", "b"] +61 61 | "a " "b".split() # ["a", "b"] + +SIM905.py:59:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +57 | # prefixes and isc +58 | u"a b".split() # [u"a", u"b"] +59 | r"a \n b".split() # [r"a", r"\n", r"b"] + | ^^^^^^^^^^^^^^^^^ SIM905 +60 | ("a " "b").split() # ["a", "b"] +61 | "a " "b".split() # ["a", "b"] + | + = help: Replace with list literal + +ℹ Safe fix +56 56 | +57 57 | # prefixes and isc +58 58 | u"a b".split() # [u"a", u"b"] +59 |-r"a \n b".split() # [r"a", r"\n", r"b"] + 59 |+[r"a", r"\n", r"b"] # [r"a", r"\n", r"b"] +60 60 | ("a " "b").split() # ["a", "b"] +61 61 | "a " "b".split() # ["a", "b"] +62 62 | u"a " "b".split() # [u"a", u"b"] + +SIM905.py:60:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +58 | u"a b".split() # [u"a", u"b"] +59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 | ("a " "b").split() # ["a", "b"] + | ^^^^^^^^^^^^^^^^^^ SIM905 +61 | "a " "b".split() # ["a", "b"] +62 | u"a " "b".split() # [u"a", u"b"] + | + = help: Replace with list literal + +ℹ Safe fix +57 57 | # prefixes and isc +58 58 | u"a b".split() # [u"a", u"b"] +59 59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 |-("a " "b").split() # ["a", "b"] + 60 |+["a", "b"] # ["a", "b"] +61 61 | "a " "b".split() # ["a", "b"] +62 62 | u"a " "b".split() # [u"a", u"b"] +63 63 | "a " u"b".split() # ["a", "b"] + +SIM905.py:61:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 | ("a " "b").split() # ["a", "b"] +61 | "a " "b".split() # ["a", "b"] + | ^^^^^^^^^^^^^^^^ SIM905 +62 | u"a " "b".split() # [u"a", u"b"] +63 | "a " u"b".split() # ["a", "b"] + | + = help: Replace with list literal + +ℹ Safe fix +58 58 | u"a b".split() # [u"a", u"b"] +59 59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 60 | ("a " "b").split() # ["a", "b"] +61 |-"a " "b".split() # ["a", "b"] + 61 |+["a", "b"] # ["a", "b"] +62 62 | u"a " "b".split() # [u"a", u"b"] +63 63 | "a " u"b".split() # ["a", "b"] +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] + +SIM905.py:62:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +60 | ("a " "b").split() # ["a", "b"] +61 | "a " "b".split() # ["a", "b"] +62 | u"a " "b".split() # [u"a", u"b"] + | ^^^^^^^^^^^^^^^^^ SIM905 +63 | "a " u"b".split() # ["a", "b"] +64 | u"a " r"\n".split() # [u"a", u"\\n"] + | + = help: Replace with list literal + +ℹ Safe fix +59 59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 60 | ("a " "b").split() # ["a", "b"] +61 61 | "a " "b".split() # ["a", "b"] +62 |-u"a " "b".split() # [u"a", u"b"] + 62 |+[u"a", u"b"] # [u"a", u"b"] +63 63 | "a " u"b".split() # ["a", "b"] +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 65 | r"\n " u"\n".split() # [r"\n"] + +SIM905.py:63:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +61 | "a " "b".split() # ["a", "b"] +62 | u"a " "b".split() # [u"a", u"b"] +63 | "a " u"b".split() # ["a", "b"] + | ^^^^^^^^^^^^^^^^^ SIM905 +64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 | r"\n " u"\n".split() # [r"\n"] + | + = help: Replace with list literal + +ℹ Safe fix +60 60 | ("a " "b").split() # ["a", "b"] +61 61 | "a " "b".split() # ["a", "b"] +62 62 | u"a " "b".split() # [u"a", u"b"] +63 |-"a " u"b".split() # ["a", "b"] + 63 |+["a", "b"] # ["a", "b"] +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 65 | r"\n " u"\n".split() # [r"\n"] +66 66 | r"\n " "\n".split() # [r"\n"] + +SIM905.py:64:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +62 | u"a " "b".split() # [u"a", u"b"] +63 | "a " u"b".split() # ["a", "b"] +64 | u"a " r"\n".split() # [u"a", u"\\n"] + | ^^^^^^^^^^^^^^^^^^^ SIM905 +65 | r"\n " u"\n".split() # [r"\n"] +66 | r"\n " "\n".split() # [r"\n"] + | + = help: Replace with list literal + +ℹ Safe fix +61 61 | "a " "b".split() # ["a", "b"] +62 62 | u"a " "b".split() # [u"a", u"b"] +63 63 | "a " u"b".split() # ["a", "b"] +64 |-u"a " r"\n".split() # [u"a", u"\\n"] + 64 |+[u"a", u"\\n"] # [u"a", u"\\n"] +65 65 | r"\n " u"\n".split() # [r"\n"] +66 66 | r"\n " "\n".split() # [r"\n"] +67 67 | "a " r"\n".split() # ["a", "\\n"] + +SIM905.py:65:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +63 | "a " u"b".split() # ["a", "b"] +64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 | r"\n " u"\n".split() # [r"\n"] + | ^^^^^^^^^^^^^^^^^^^^ SIM905 +66 | r"\n " "\n".split() # [r"\n"] +67 | "a " r"\n".split() # ["a", "\\n"] + | + = help: Replace with list literal + +ℹ Safe fix +62 62 | u"a " "b".split() # [u"a", u"b"] +63 63 | "a " u"b".split() # ["a", "b"] +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 |-r"\n " u"\n".split() # [r"\n"] + 65 |+[r"\n"] # [r"\n"] +66 66 | r"\n " "\n".split() # [r"\n"] +67 67 | "a " r"\n".split() # ["a", "\\n"] +68 68 | + +SIM905.py:66:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 | r"\n " u"\n".split() # [r"\n"] +66 | r"\n " "\n".split() # [r"\n"] + | ^^^^^^^^^^^^^^^^^^^ SIM905 +67 | "a " r"\n".split() # ["a", "\\n"] + | + = help: Replace with list literal + +ℹ Safe fix +63 63 | "a " u"b".split() # ["a", "b"] +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 65 | r"\n " u"\n".split() # [r"\n"] +66 |-r"\n " "\n".split() # [r"\n"] + 66 |+[r"\n"] # [r"\n"] +67 67 | "a " r"\n".split() # ["a", "\\n"] +68 68 | +69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] + +SIM905.py:67:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +65 | r"\n " u"\n".split() # [r"\n"] +66 | r"\n " "\n".split() # [r"\n"] +67 | "a " r"\n".split() # ["a", "\\n"] + | ^^^^^^^^^^^^^^^^^^ SIM905 +68 | +69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] + | + = help: Replace with list literal + +ℹ Safe fix +64 64 | u"a " r"\n".split() # [u"a", u"\\n"] +65 65 | r"\n " u"\n".split() # [r"\n"] +66 66 | r"\n " "\n".split() # [r"\n"] +67 |-"a " r"\n".split() # ["a", "\\n"] + 67 |+["a", "\\n"] # ["a", "\\n"] +68 68 | +69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] + +SIM905.py:69:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +67 | "a " r"\n".split() # ["a", "\\n"] +68 | +69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] + | + = help: Replace with list literal + +ℹ Safe fix +66 66 | r"\n " "\n".split() # [r"\n"] +67 67 | "a " r"\n".split() # ["a", "\\n"] +68 68 | +69 |-"a,b,c".split(',', maxsplit=0) # ["a,b,c"] + 69 |+["a,b,c"] # ["a,b,c"] +70 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] +72 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] + +SIM905.py:70:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] +72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] + | + = help: Replace with list literal + +ℹ Safe fix +67 67 | "a " r"\n".split() # ["a", "\\n"] +68 68 | +69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 |-"a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] + 70 |+["a", "b", "c"] # ["a", "b", "c"] +71 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] +72 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] +73 73 | + +SIM905.py:71:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] + | + = help: Replace with list literal + +ℹ Safe fix +68 68 | +69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 |-"a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] + 71 |+["a", "b", "c"] # ["a", "b", "c"] +72 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] +73 73 | +74 74 | # negatives + +SIM905.py:72:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] +72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +73 | +74 | # negatives + | + = help: Replace with list literal + +ℹ Safe fix +69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] +70 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] +71 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] +72 |-"a,b,c".split(',', maxsplit=-0) # ["a,b,c"] + 72 |+["a,b,c"] # ["a,b,c"] +73 73 | +74 74 | # negatives +75 75 | + +SIM905.py:103:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +102 | # another positive demonstrating quote preservation +103 | / """ +104 | | "itemA" +105 | | 'itemB' +106 | | '''itemC''' +107 | | "'itemD'" +108 | | """.split() + | |___________^ SIM905 +109 | +110 | # https://github.com/astral-sh/ruff/issues/18042 + | + = help: Replace with list literal + +ℹ Safe fix +100 100 | +101 101 | +102 102 | # another positive demonstrating quote preservation +103 |-""" +104 |-"itemA" +105 |-'itemB' +106 |-'''itemC''' +107 |-"'itemD'" +108 |-""".split() + 103 |+['"itemA"', "'itemB'", "'''itemC'''", "\"'itemD'\""] +109 104 | +110 105 | # https://github.com/astral-sh/ruff/issues/18042 +111 106 | print("a,b".rsplit(",")) + +SIM905.py:111:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +110 | # https://github.com/astral-sh/ruff/issues/18042 +111 | print("a,b".rsplit(",")) + | ^^^^^^^^^^^^^^^^^ SIM905 +112 | print("a,b,c".rsplit(",", 1)) + | + = help: Replace with list literal + +ℹ Safe fix +108 108 | """.split() +109 109 | +110 110 | # https://github.com/astral-sh/ruff/issues/18042 +111 |-print("a,b".rsplit(",")) + 111 |+print(["a", "b"]) +112 112 | print("a,b,c".rsplit(",", 1)) +113 113 | +114 114 | # https://github.com/astral-sh/ruff/issues/18069 + +SIM905.py:112:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +110 | # https://github.com/astral-sh/ruff/issues/18042 +111 | print("a,b".rsplit(",")) +112 | print("a,b,c".rsplit(",", 1)) + | ^^^^^^^^^^^^^^^^^^^^^^ SIM905 +113 | +114 | # https://github.com/astral-sh/ruff/issues/18069 + | + = help: Replace with list literal + +ℹ Safe fix +109 109 | +110 110 | # https://github.com/astral-sh/ruff/issues/18042 +111 111 | print("a,b".rsplit(",")) +112 |-print("a,b,c".rsplit(",", 1)) + 112 |+print(["a,b", "c"]) +113 113 | +114 114 | # https://github.com/astral-sh/ruff/issues/18069 +115 115 | + +SIM905.py:116:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +114 | # https://github.com/astral-sh/ruff/issues/18069 +115 | +116 | print("".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^ SIM905 +117 | print("".split(sep=None, maxsplit=0)) +118 | print(" ".split(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +113 113 | +114 114 | # https://github.com/astral-sh/ruff/issues/18069 +115 115 | +116 |-print("".split(maxsplit=0)) + 116 |+print([]) +117 117 | print("".split(sep=None, maxsplit=0)) +118 118 | print(" ".split(maxsplit=0)) +119 119 | print(" ".split(sep=None, maxsplit=0)) + +SIM905.py:117:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +116 | print("".split(maxsplit=0)) +117 | print("".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +118 | print(" ".split(maxsplit=0)) +119 | print(" ".split(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +114 114 | # https://github.com/astral-sh/ruff/issues/18069 +115 115 | +116 116 | print("".split(maxsplit=0)) +117 |-print("".split(sep=None, maxsplit=0)) + 117 |+print([]) +118 118 | print(" ".split(maxsplit=0)) +119 119 | print(" ".split(sep=None, maxsplit=0)) +120 120 | print(" x ".split(maxsplit=0)) + +SIM905.py:118:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +116 | print("".split(maxsplit=0)) +117 | print("".split(sep=None, maxsplit=0)) +118 | print(" ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^ SIM905 +119 | print(" ".split(sep=None, maxsplit=0)) +120 | print(" x ".split(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +115 115 | +116 116 | print("".split(maxsplit=0)) +117 117 | print("".split(sep=None, maxsplit=0)) +118 |-print(" ".split(maxsplit=0)) + 118 |+print([]) +119 119 | print(" ".split(sep=None, maxsplit=0)) +120 120 | print(" x ".split(maxsplit=0)) +121 121 | print(" x ".split(sep=None, maxsplit=0)) + +SIM905.py:119:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +117 | print("".split(sep=None, maxsplit=0)) +118 | print(" ".split(maxsplit=0)) +119 | print(" ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +120 | print(" x ".split(maxsplit=0)) +121 | print(" x ".split(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +116 116 | print("".split(maxsplit=0)) +117 117 | print("".split(sep=None, maxsplit=0)) +118 118 | print(" ".split(maxsplit=0)) +119 |-print(" ".split(sep=None, maxsplit=0)) + 119 |+print([]) +120 120 | print(" x ".split(maxsplit=0)) +121 121 | print(" x ".split(sep=None, maxsplit=0)) +122 122 | print(" x ".split(maxsplit=0)) + +SIM905.py:120:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +118 | print(" ".split(maxsplit=0)) +119 | print(" ".split(sep=None, maxsplit=0)) +120 | print(" x ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +121 | print(" x ".split(sep=None, maxsplit=0)) +122 | print(" x ".split(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +117 117 | print("".split(sep=None, maxsplit=0)) +118 118 | print(" ".split(maxsplit=0)) +119 119 | print(" ".split(sep=None, maxsplit=0)) +120 |-print(" x ".split(maxsplit=0)) + 120 |+print(["x "]) +121 121 | print(" x ".split(sep=None, maxsplit=0)) +122 122 | print(" x ".split(maxsplit=0)) +123 123 | print(" x ".split(sep=None, maxsplit=0)) + +SIM905.py:121:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +119 | print(" ".split(sep=None, maxsplit=0)) +120 | print(" x ".split(maxsplit=0)) +121 | print(" x ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +122 | print(" x ".split(maxsplit=0)) +123 | print(" x ".split(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +118 118 | print(" ".split(maxsplit=0)) +119 119 | print(" ".split(sep=None, maxsplit=0)) +120 120 | print(" x ".split(maxsplit=0)) +121 |-print(" x ".split(sep=None, maxsplit=0)) + 121 |+print(["x "]) +122 122 | print(" x ".split(maxsplit=0)) +123 123 | print(" x ".split(sep=None, maxsplit=0)) +124 124 | print("".rsplit(maxsplit=0)) + +SIM905.py:122:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +120 | print(" x ".split(maxsplit=0)) +121 | print(" x ".split(sep=None, maxsplit=0)) +122 | print(" x ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +123 | print(" x ".split(sep=None, maxsplit=0)) +124 | print("".rsplit(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +119 119 | print(" ".split(sep=None, maxsplit=0)) +120 120 | print(" x ".split(maxsplit=0)) +121 121 | print(" x ".split(sep=None, maxsplit=0)) +122 |-print(" x ".split(maxsplit=0)) + 122 |+print(["x "]) +123 123 | print(" x ".split(sep=None, maxsplit=0)) +124 124 | print("".rsplit(maxsplit=0)) +125 125 | print("".rsplit(sep=None, maxsplit=0)) + +SIM905.py:123:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +121 | print(" x ".split(sep=None, maxsplit=0)) +122 | print(" x ".split(maxsplit=0)) +123 | print(" x ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +124 | print("".rsplit(maxsplit=0)) +125 | print("".rsplit(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +120 120 | print(" x ".split(maxsplit=0)) +121 121 | print(" x ".split(sep=None, maxsplit=0)) +122 122 | print(" x ".split(maxsplit=0)) +123 |-print(" x ".split(sep=None, maxsplit=0)) + 123 |+print(["x "]) +124 124 | print("".rsplit(maxsplit=0)) +125 125 | print("".rsplit(sep=None, maxsplit=0)) +126 126 | print(" ".rsplit(maxsplit=0)) + +SIM905.py:124:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +122 | print(" x ".split(maxsplit=0)) +123 | print(" x ".split(sep=None, maxsplit=0)) +124 | print("".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^ SIM905 +125 | print("".rsplit(sep=None, maxsplit=0)) +126 | print(" ".rsplit(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +121 121 | print(" x ".split(sep=None, maxsplit=0)) +122 122 | print(" x ".split(maxsplit=0)) +123 123 | print(" x ".split(sep=None, maxsplit=0)) +124 |-print("".rsplit(maxsplit=0)) + 124 |+print([]) +125 125 | print("".rsplit(sep=None, maxsplit=0)) +126 126 | print(" ".rsplit(maxsplit=0)) +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) + +SIM905.py:125:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +123 | print(" x ".split(sep=None, maxsplit=0)) +124 | print("".rsplit(maxsplit=0)) +125 | print("".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +126 | print(" ".rsplit(maxsplit=0)) +127 | print(" ".rsplit(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +122 122 | print(" x ".split(maxsplit=0)) +123 123 | print(" x ".split(sep=None, maxsplit=0)) +124 124 | print("".rsplit(maxsplit=0)) +125 |-print("".rsplit(sep=None, maxsplit=0)) + 125 |+print([]) +126 126 | print(" ".rsplit(maxsplit=0)) +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 128 | print(" x ".rsplit(maxsplit=0)) + +SIM905.py:126:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +124 | print("".rsplit(maxsplit=0)) +125 | print("".rsplit(sep=None, maxsplit=0)) +126 | print(" ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^ SIM905 +127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 | print(" x ".rsplit(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +123 123 | print(" x ".split(sep=None, maxsplit=0)) +124 124 | print("".rsplit(maxsplit=0)) +125 125 | print("".rsplit(sep=None, maxsplit=0)) +126 |-print(" ".rsplit(maxsplit=0)) + 126 |+print([]) +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 128 | print(" x ".rsplit(maxsplit=0)) +129 129 | print(" x ".rsplit(maxsplit=0)) + +SIM905.py:127:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +125 | print("".rsplit(sep=None, maxsplit=0)) +126 | print(" ".rsplit(maxsplit=0)) +127 | print(" ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +128 | print(" x ".rsplit(maxsplit=0)) +129 | print(" x ".rsplit(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +124 124 | print("".rsplit(maxsplit=0)) +125 125 | print("".rsplit(sep=None, maxsplit=0)) +126 126 | print(" ".rsplit(maxsplit=0)) +127 |-print(" ".rsplit(sep=None, maxsplit=0)) + 127 |+print([]) +128 128 | print(" x ".rsplit(maxsplit=0)) +129 129 | print(" x ".rsplit(maxsplit=0)) +130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) + +SIM905.py:128:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +126 | print(" ".rsplit(maxsplit=0)) +127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +129 | print(" x ".rsplit(maxsplit=0)) +130 | print(" x ".rsplit(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +125 125 | print("".rsplit(sep=None, maxsplit=0)) +126 126 | print(" ".rsplit(maxsplit=0)) +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 |-print(" x ".rsplit(maxsplit=0)) + 128 |+print([" x"]) +129 129 | print(" x ".rsplit(maxsplit=0)) +130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 131 | print(" x ".rsplit(maxsplit=0)) + +SIM905.py:129:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 | print(" x ".rsplit(maxsplit=0)) +129 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 | print(" x ".rsplit(maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +126 126 | print(" ".rsplit(maxsplit=0)) +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 128 | print(" x ".rsplit(maxsplit=0)) +129 |-print(" x ".rsplit(maxsplit=0)) + 129 |+print([" x"]) +130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 131 | print(" x ".rsplit(maxsplit=0)) +132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) + +SIM905.py:130:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +128 | print(" x ".rsplit(maxsplit=0)) +129 | print(" x ".rsplit(maxsplit=0)) +130 | print(" x ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +131 | print(" x ".rsplit(maxsplit=0)) +132 | print(" x ".rsplit(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +127 127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 128 | print(" x ".rsplit(maxsplit=0)) +129 129 | print(" x ".rsplit(maxsplit=0)) +130 |-print(" x ".rsplit(sep=None, maxsplit=0)) + 130 |+print([" x"]) +131 131 | print(" x ".rsplit(maxsplit=0)) +132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | + +SIM905.py:131:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +129 | print(" x ".rsplit(maxsplit=0)) +130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +132 | print(" x ".rsplit(sep=None, maxsplit=0)) + | + = help: Replace with list literal + +ℹ Safe fix +128 128 | print(" x ".rsplit(maxsplit=0)) +129 129 | print(" x ".rsplit(maxsplit=0)) +130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 |-print(" x ".rsplit(maxsplit=0)) + 131 |+print([" x"]) +132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 + +SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` + | +130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 | print(" x ".rsplit(maxsplit=0)) +132 | print(" x ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +133 | +134 | # https://github.com/astral-sh/ruff/issues/19610 + | + = help: Replace with list literal + +ℹ Safe fix +129 129 | print(" x ".rsplit(maxsplit=0)) +130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 131 | print(" x ".rsplit(maxsplit=0)) +132 |-print(" x ".rsplit(sep=None, maxsplit=0)) + 132 |+print([" x"]) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] + +SIM905.py:135:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ SIM905 +136 | r"" "\"".split("1") # ['"'] +137 | r"1" """ + | + = help: Replace with list literal + +ℹ Safe fix +132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 |-r"1" "\n".split("1") # [r"", "\n"] + 135 |+[r"", '\n'] # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] + +SIM905.py:136:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ SIM905 +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] + | + = help: Replace with list literal + +ℹ Safe fix +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 |-r"" "\"".split("1") # ['"'] + 136 |+[r'"'] # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] +139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905.py:137:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] +137 | / r"1" """ +138 | | """.split("1") # [r"", "\n"] + | |______________^ SIM905 +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | + = help: Replace with list literal + +ℹ Safe fix +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 |-r"1" """ +138 |-""".split("1") # [r"", "\n"] + 137 |+[r"", '\n'] # [r"", "\n"] +139 138 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] +140 139 | +141 140 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings + +SIM905.py:139:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 +140 | +141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings + | + = help: Replace with list literal + +ℹ Safe fix +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] +139 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] + 139 |+['\\n\n\'"'] # ["\\n\n'\""] +140 140 | +141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 142 | r"""simple@example.com + +SIM905.py:142:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 | / r"""simple@example.com +143 | | very.common@example.com +144 | | FirstName.LastName@EasierReading.org +145 | | x@example.com +146 | | long.email-address-with-hyphens@and.subdomains.example.com +147 | | user.name+tag+sorting@example.com +148 | | name/surname@example.com +149 | | xample@s.example +150 | | " "@example.org +151 | | "john..doe"@example.org +152 | | mailhost!username@example.org +153 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +154 | | user%example.com@example.org +155 | | user-@example.org +156 | | I❤️CHOCOLATE@example.com +157 | | this\ still\"not\\allowed@example.com +158 | | stellyamburrr985@example.com +159 | | Abc.123@example.com +160 | | user+mailbox/department=shipping@example.com +161 | | !#$%&'*+-/=?^_`.{|}~@example.com +162 | | "Abc@def"@example.com +163 | | "Fred\ Bloggs"@example.com +164 | | "Joe.\\Blow"@example.com""".split("\n") + | |_______________________________________^ SIM905 + | + = help: Replace with list literal + +ℹ Safe fix +139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] +140 140 | +141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 |-r"""simple@example.com +143 |-very.common@example.com +144 |-FirstName.LastName@EasierReading.org +145 |-x@example.com +146 |-long.email-address-with-hyphens@and.subdomains.example.com +147 |-user.name+tag+sorting@example.com +148 |-name/surname@example.com +149 |-xample@s.example +150 |-" "@example.org +151 |-"john..doe"@example.org +152 |-mailhost!username@example.org +153 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +154 |-user%example.com@example.org +155 |-user-@example.org +156 |-I❤️CHOCOLATE@example.com +157 |-this\ still\"not\\allowed@example.com +158 |-stellyamburrr985@example.com +159 |-Abc.123@example.com +160 |-user+mailbox/department=shipping@example.com +161 |-!#$%&'*+-/=?^_`.{|}~@example.com +162 |-"Abc@def"@example.com +163 |-"Fred\ Bloggs"@example.com +164 |-"Joe.\\Blow"@example.com""".split("\n") + 142 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] +165 143 | +166 144 | +167 145 | r"""first + +SIM905.py:167:1: SIM905 [*] Consider using a list literal instead of `str.split` + | +167 | / r"""first +168 | | 'no need' to escape +169 | | "swap" quote style +170 | | "use' ugly triple quotes""".split("\n") + | |_______________________________________^ SIM905 + | + = help: Replace with list literal + +ℹ Safe fix +164 164 | "Joe.\\Blow"@example.com""".split("\n") +165 165 | +166 166 | +167 |-r"""first +168 |-'no need' to escape +169 |-"swap" quote style +170 |-"use' ugly triple quotes""".split("\n") + 167 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] From e58c51fb347d322c40bf9857daa5abfecdd27142 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 20 Aug 2025 21:48:06 -0400 Subject: [PATCH 5/7] Update ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap --- ...ify__tests__preview__SIM905_SIM905.py.snap | 356 +++++++++++------- 1 file changed, 222 insertions(+), 134 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap index e45eabb21c..b7cba4c42e 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap @@ -1367,7 +1367,7 @@ help: Replace with list literal 131 |+print([" x"]) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +134 134 | # https://github.com/astral-sh/ruff/issues/19610 SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:132:7 @@ -1377,7 +1377,7 @@ SIM905 [*] Consider using a list literal instead of `str.split` 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 133 | -134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +134 | # https://github.com/astral-sh/ruff/issues/19610 | help: Replace with list literal @@ -1388,193 +1388,281 @@ help: Replace with list literal 132 |-print(" x ".rsplit(sep=None, maxsplit=0)) 132 |+print([" x"]) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -135 135 | r"""simple@example.com +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:135:1 | -134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -135 | / r"""simple@example.com -136 | | very.common@example.com -137 | | FirstName.LastName@EasierReading.org -138 | | x@example.com -139 | | long.email-address-with-hyphens@and.subdomains.example.com -140 | | user.name+tag+sorting@example.com -141 | | name/surname@example.com -142 | | xample@s.example -143 | | " "@example.org -144 | | "john..doe"@example.org -145 | | mailhost!username@example.org -146 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -147 | | user%example.com@example.org -148 | | user-@example.org -149 | | I❤️CHOCOLATE@example.com -150 | | this\ still\"not\\allowed@example.com -151 | | stellyamburrr985@example.com -152 | | Abc.123@example.com -153 | | user+mailbox/department=shipping@example.com -154 | | !#$%&'*+-/=?^_`.{|}~@example.com -155 | | "Abc@def"@example.com -156 | | "Fred\ Bloggs"@example.com -157 | | "Joe.\\Blow"@example.com""".split("\n") - | |_______________________________________^ +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ +136 | r"" "\"".split("1") # ['"'] +137 | r"1" """ | help: Replace with list literal ℹ Safe fix 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -135 |-r"""simple@example.com -136 |-very.common@example.com -137 |-FirstName.LastName@EasierReading.org -138 |-x@example.com -139 |-long.email-address-with-hyphens@and.subdomains.example.com -140 |-user.name+tag+sorting@example.com -141 |-name/surname@example.com -142 |-xample@s.example -143 |-" "@example.org -144 |-"john..doe"@example.org -145 |-mailhost!username@example.org -146 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -147 |-user%example.com@example.org -148 |-user-@example.org -149 |-I❤️CHOCOLATE@example.com -150 |-this\ still\"not\\allowed@example.com -151 |-stellyamburrr985@example.com -152 |-Abc.123@example.com -153 |-user+mailbox/department=shipping@example.com -154 |-!#$%&'*+-/=?^_`.{|}~@example.com -155 |-"Abc@def"@example.com -156 |-"Fred\ Bloggs"@example.com -157 |-"Joe.\\Blow"@example.com""".split("\n") - 135 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] -158 136 | -159 137 | -160 138 | r"""first +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 |-r"1" "\n".split("1") # [r"", "\n"] + 135 |+[r"", '\n'] # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:160:1 + --> SIM905.py:136:1 | -160 | / r"""first -161 | | 'no need' to escape -162 | | "swap" quote style -163 | | "use' ugly triple quotes""".split("\n") +134 | # https://github.com/astral-sh/ruff/issues/19610 +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] + | +help: Replace with list literal + +ℹ Safe fix +133 133 | +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 |-r"" "\"".split("1") # ['"'] + 136 |+[r'"'] # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] +139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:137:1 + | +135 | r"1" "\n".split("1") # [r"", "\n"] +136 | r"" "\"".split("1") # ['"'] +137 | / r"1" """ +138 | | """.split("1") # [r"", "\n"] + | |______________^ +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | +help: Replace with list literal + +ℹ Safe fix +134 134 | # https://github.com/astral-sh/ruff/issues/19610 +135 135 | r"1" "\n".split("1") # [r"", "\n"] +136 136 | r"" "\"".split("1") # ['"'] +137 |-r"1" """ +138 |-""".split("1") # [r"", "\n"] + 137 |+[r"", '\n'] # [r"", "\n"] +139 138 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] +140 139 | +141 140 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:139:1 + | +137 | r"1" """ +138 | """.split("1") # [r"", "\n"] +139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ +140 | +141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings + | +help: Replace with list literal + +ℹ Safe fix +136 136 | r"" "\"".split("1") # ['"'] +137 137 | r"1" """ +138 138 | """.split("1") # [r"", "\n"] +139 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] + 139 |+['\\n\n\'"'] # ["\\n\n'\""] +140 140 | +141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 142 | r"""simple@example.com + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:142:1 + | +141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 | / r"""simple@example.com +143 | | very.common@example.com +144 | | FirstName.LastName@EasierReading.org +145 | | x@example.com +146 | | long.email-address-with-hyphens@and.subdomains.example.com +147 | | user.name+tag+sorting@example.com +148 | | name/surname@example.com +149 | | xample@s.example +150 | | " "@example.org +151 | | "john..doe"@example.org +152 | | mailhost!username@example.org +153 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +154 | | user%example.com@example.org +155 | | user-@example.org +156 | | I❤️CHOCOLATE@example.com +157 | | this\ still\"not\\allowed@example.com +158 | | stellyamburrr985@example.com +159 | | Abc.123@example.com +160 | | user+mailbox/department=shipping@example.com +161 | | !#$%&'*+-/=?^_`.{|}~@example.com +162 | | "Abc@def"@example.com +163 | | "Fred\ Bloggs"@example.com +164 | | "Joe.\\Blow"@example.com""".split("\n") | |_______________________________________^ -164 | -165 | # https://github.com/astral-sh/ruff/issues/19845 | help: Replace with list literal ℹ Safe fix -157 157 | "Joe.\\Blow"@example.com""".split("\n") -158 158 | -159 159 | -160 |-r"""first -161 |-'no need' to escape -162 |-"swap" quote style -163 |-"use' ugly triple quotes""".split("\n") - 160 |+[r"first", r"'no need' to escape", r'"swap" quote style', r""""use' ugly triple quotes"""] -164 161 | -165 162 | # https://github.com/astral-sh/ruff/issues/19845 -166 163 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] +140 140 | +141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +142 |-r"""simple@example.com +143 |-very.common@example.com +144 |-FirstName.LastName@EasierReading.org +145 |-x@example.com +146 |-long.email-address-with-hyphens@and.subdomains.example.com +147 |-user.name+tag+sorting@example.com +148 |-name/surname@example.com +149 |-xample@s.example +150 |-" "@example.org +151 |-"john..doe"@example.org +152 |-mailhost!username@example.org +153 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +154 |-user%example.com@example.org +155 |-user-@example.org +156 |-I❤️CHOCOLATE@example.com +157 |-this\ still\"not\\allowed@example.com +158 |-stellyamburrr985@example.com +159 |-Abc.123@example.com +160 |-user+mailbox/department=shipping@example.com +161 |-!#$%&'*+-/=?^_`.{|}~@example.com +162 |-"Abc@def"@example.com +163 |-"Fred\ Bloggs"@example.com +164 |-"Joe.\\Blow"@example.com""".split("\n") + 142 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] +165 143 | +166 144 | +167 145 | r"""first SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:166:7 + --> SIM905.py:167:1 | -165 | # https://github.com/astral-sh/ruff/issues/19845 -166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 | / r"""first +168 | | 'no need' to escape +169 | | "swap" quote style +170 | | "use' ugly triple quotes""".split("\n") + | |_______________________________________^ +171 | +172 | # https://github.com/astral-sh/ruff/issues/19845 + | +help: Replace with list literal + +ℹ Safe fix +164 164 | "Joe.\\Blow"@example.com""".split("\n") +165 165 | +166 166 | +167 |-r"""first +168 |-'no need' to escape +169 |-"swap" quote style +170 |-"use' ugly triple quotes""".split("\n") + 167 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] +171 168 | +172 169 | # https://github.com/astral-sh/ruff/issues/19845 +173 170 | print("S\x1cP\x1dL\x1eI\x1fT".split()) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:173:7 + | +172 | # https://github.com/astral-sh/ruff/issues/19845 +173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -163 163 | "use' ugly triple quotes""".split("\n") -164 164 | -165 165 | # https://github.com/astral-sh/ruff/issues/19845 -166 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) - 166 |+print(["S", "P", "L", "I", "T"]) -167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -169 169 | +170 170 | "use' ugly triple quotes""".split("\n") +171 171 | +172 172 | # https://github.com/astral-sh/ruff/issues/19845 +173 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) + 173 |+print(["S", "P", "L", "I", "T"]) +174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +176 176 | SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:167:7 + --> SIM905.py:174:7 | -165 | # https://github.com/astral-sh/ruff/issues/19845 -166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +172 | # https://github.com/astral-sh/ruff/issues/19845 +173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -164 164 | -165 165 | # https://github.com/astral-sh/ruff/issues/19845 -166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -167 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) - 167 |+print([">"]) -168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -169 169 | -170 170 | # leading/trailing whitespace should not count towards maxsplit +171 171 | +172 172 | # https://github.com/astral-sh/ruff/issues/19845 +173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +174 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) + 174 |+print([">"]) +175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +176 176 | +177 177 | # leading/trailing whitespace should not count towards maxsplit SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:168:7 + --> SIM905.py:175:7 | -166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -169 | -170 | # leading/trailing whitespace should not count towards maxsplit +176 | +177 | # leading/trailing whitespace should not count towards maxsplit | help: Replace with list literal ℹ Safe fix -165 165 | # https://github.com/astral-sh/ruff/issues/19845 -166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -168 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) - 168 |+print(["<"]) -169 169 | -170 170 | # leading/trailing whitespace should not count towards maxsplit -171 171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +172 172 | # https://github.com/astral-sh/ruff/issues/19845 +173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +175 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) + 175 |+print(["<"]) +176 176 | +177 177 | # leading/trailing whitespace should not count towards maxsplit +178 178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:171:1 + --> SIM905.py:178:1 | -170 | # leading/trailing whitespace should not count towards maxsplit -171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +177 | # leading/trailing whitespace should not count towards maxsplit +178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] | help: Replace with list literal ℹ Safe fix -168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -169 169 | -170 170 | # leading/trailing whitespace should not count towards maxsplit -171 |-" a b c d ".split(maxsplit=2) # ["a", "b", "c d "] - 171 |+["a", "b", "c d "] # ["a", "b", "c d "] -172 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +176 176 | +177 177 | # leading/trailing whitespace should not count towards maxsplit +178 |-" a b c d ".split(maxsplit=2) # ["a", "b", "c d "] + 178 |+["a", "b", "c d "] # ["a", "b", "c d "] +179 179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:172:1 + --> SIM905.py:179:1 | -170 | # leading/trailing whitespace should not count towards maxsplit -171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] -172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +177 | # leading/trailing whitespace should not count towards maxsplit +178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: Replace with list literal ℹ Safe fix -169 169 | -170 170 | # leading/trailing whitespace should not count towards maxsplit -171 171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] -172 |-" a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] - 172 |+[" a b", "c", "d"] # [" a b", "c", "d"] +176 176 | +177 177 | # leading/trailing whitespace should not count towards maxsplit +178 178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +179 |-" a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] + 179 |+[" a b", "c", "d"] # [" a b", "c", "d"] From 64ae3d75ee5fe37c3630ad32f9642f9feecb28c2 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 23 Oct 2025 23:50:14 -0400 Subject: [PATCH 6/7] Fix SIM905 handling for raw strings with newlines and quotes Refactors the logic in split_static_string.rs to correctly handle raw string literals containing newlines and embedded quotes, ensuring the appropriate quote style and flags are used to avoid syntax errors. Updates test fixtures and snapshots to reflect the improved handling and corrects misplaced test cases. --- .../test/fixtures/flake8_simplify/SIM905.py | 14 +- .../rules/split_static_string.rs | 34 +- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 417 ++++++++-------- ...ify__tests__preview__SIM905_SIM905.py.snap | 444 +++++++++--------- 4 files changed, 452 insertions(+), 457 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py index 7c52b14998..0d9281cb99 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py @@ -131,13 +131,6 @@ print(" x ".rsplit(sep=None, maxsplit=0)) print(" x ".rsplit(maxsplit=0)) print(" x ".rsplit(sep=None, maxsplit=0)) -# https://github.com/astral-sh/ruff/issues/19610 -r"1" "\n".split("1") # [r"", "\n"] -r"" "\"".split("1") # ['"'] -r"1" """ -""".split("1") # [r"", "\n"] -r"\n" "\n'\"".split("1") # ["\\n\n'\""] - # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings r"""simple@example.com very.common@example.com @@ -177,3 +170,10 @@ print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) # leading/trailing whitespace should not count towards maxsplit " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] + +# https://github.com/astral-sh/ruff/issues/19610 +r"1" "\n".split("1") # [r"", "\n"] +r"" "\"".split("1") # ['"'] +r"1" """ +""".split("1") # [r"", "\n"] +r"\n" "\n'\"".split("1") # ["\\n\n'\""] diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs index f508e4e1da..367e5a7507 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/split_static_string.rs @@ -135,27 +135,27 @@ fn replace_flags(elt: &str, flags: StringLiteralFlags) -> StringLiteralFlags { // 'single'quoted // """.split() # -> [r"itemA",r"'single'quoted'"] // ``` - if !flags.prefix().is_raw() { - return flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); - } - - if elt.contains('\n') || elt.contains('\r') { - return StringLiteralFlags::empty() - .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); - } - - if elt.contains(flags.quote_style().as_char()) { + flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) + } else if elt.contains(['\n', '\r']) { + // If the element contains newlines or carriage returns, we need to use + // default flags (no raw prefix) to avoid syntax errors + StringLiteralFlags::empty() + } else if elt.contains(flags.quote_style().as_char()) { + // If we have a raw string containing a quotation mark of the same style, + // then we have to swap the style of quotation marks used if elt.contains(flags.quote_style().opposite().as_char()) { - return StringLiteralFlags::empty() - .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); + // If both types of quotes are used in the raw string, then + // we are forced to use default flags to avoid syntax errors + StringLiteralFlags::empty() + } else { + flags + .with_quote_style(flags.quote_style().opposite()) + .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) } - return flags - .with_quote_style(flags.quote_style().opposite()) - .with_triple_quotes(ruff_python_ast::str::TripleQuotes::No); + } else { + flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) } - - flags.with_triple_quotes(ruff_python_ast::str::TripleQuotes::No) } fn construct_replacement(elts: &[&str], flags: StringLiteralFlags) -> Expr { diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap index 98eba16af7..ed52d17a68 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -1307,7 +1307,7 @@ help: Replace with list literal 131 |+print([" x"]) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:132:7 @@ -1317,7 +1317,7 @@ SIM905 [*] Consider using a list literal instead of `str.split` 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 133 | -134 | # https://github.com/astral-sh/ruff/issues/19610 +134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings | help: Replace with list literal @@ -1328,266 +1328,261 @@ help: Replace with list literal 132 |-print(" x ".rsplit(sep=None, maxsplit=0)) 132 |+print([" x"]) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 135 | r"""simple@example.com SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:135:1 | -134 | # https://github.com/astral-sh/ruff/issues/19610 -135 | r"1" "\n".split("1") # [r"", "\n"] - | ^^^^^^^^^^^^^^^^^^^^ -136 | r"" "\"".split("1") # ['"'] -137 | r"1" """ +134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 | / r"""simple@example.com +136 | | very.common@example.com +137 | | FirstName.LastName@EasierReading.org +138 | | x@example.com +139 | | long.email-address-with-hyphens@and.subdomains.example.com +140 | | user.name+tag+sorting@example.com +141 | | name/surname@example.com +142 | | xample@s.example +143 | | " "@example.org +144 | | "john..doe"@example.org +145 | | mailhost!username@example.org +146 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +147 | | user%example.com@example.org +148 | | user-@example.org +149 | | I❤️CHOCOLATE@example.com +150 | | this\ still\"not\\allowed@example.com +151 | | stellyamburrr985@example.com +152 | | Abc.123@example.com +153 | | user+mailbox/department=shipping@example.com +154 | | !#$%&'*+-/=?^_`.{|}~@example.com +155 | | "Abc@def"@example.com +156 | | "Fred\ Bloggs"@example.com +157 | | "Joe.\\Blow"@example.com""".split("\n") + | |_______________________________________^ | help: Replace with list literal ℹ Safe fix 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 |-r"1" "\n".split("1") # [r"", "\n"] - 135 |+[r"", '\n'] # [r"", "\n"] -136 136 | r"" "\"".split("1") # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 |-r"""simple@example.com +136 |-very.common@example.com +137 |-FirstName.LastName@EasierReading.org +138 |-x@example.com +139 |-long.email-address-with-hyphens@and.subdomains.example.com +140 |-user.name+tag+sorting@example.com +141 |-name/surname@example.com +142 |-xample@s.example +143 |-" "@example.org +144 |-"john..doe"@example.org +145 |-mailhost!username@example.org +146 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +147 |-user%example.com@example.org +148 |-user-@example.org +149 |-I❤️CHOCOLATE@example.com +150 |-this\ still\"not\\allowed@example.com +151 |-stellyamburrr985@example.com +152 |-Abc.123@example.com +153 |-user+mailbox/department=shipping@example.com +154 |-!#$%&'*+-/=?^_`.{|}~@example.com +155 |-"Abc@def"@example.com +156 |-"Fred\ Bloggs"@example.com +157 |-"Joe.\\Blow"@example.com""".split("\n") + 135 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] +158 136 | +159 137 | +160 138 | r"""first SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:136:1 + --> SIM905.py:160:1 | -134 | # https://github.com/astral-sh/ruff/issues/19610 -135 | r"1" "\n".split("1") # [r"", "\n"] -136 | r"" "\"".split("1") # ['"'] - | ^^^^^^^^^^^^^^^^^^^ -137 | r"1" """ -138 | """.split("1") # [r"", "\n"] - | -help: Replace with list literal - -ℹ Safe fix -133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] -136 |-r"" "\"".split("1") # ['"'] - 136 |+[r'"'] # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] -139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:137:1 - | -135 | r"1" "\n".split("1") # [r"", "\n"] -136 | r"" "\"".split("1") # ['"'] -137 | / r"1" """ -138 | | """.split("1") # [r"", "\n"] - | |______________^ -139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - | -help: Replace with list literal - -ℹ Safe fix -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] -136 136 | r"" "\"".split("1") # ['"'] -137 |-r"1" """ -138 |-""".split("1") # [r"", "\n"] - 137 |+[r"", '\n'] # [r"", "\n"] -139 138 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] -140 139 | -141 140 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:139:1 - | -137 | r"1" """ -138 | """.split("1") # [r"", "\n"] -139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - | ^^^^^^^^^^^^^^^^^^^^^^^^ -140 | -141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings - | -help: Replace with list literal - -ℹ Safe fix -136 136 | r"" "\"".split("1") # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] -139 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] - 139 |+['\\n\n\'"'] # ["\\n\n'\""] -140 140 | -141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 142 | r"""simple@example.com - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:142:1 - | -141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 | / r"""simple@example.com -143 | | very.common@example.com -144 | | FirstName.LastName@EasierReading.org -145 | | x@example.com -146 | | long.email-address-with-hyphens@and.subdomains.example.com -147 | | user.name+tag+sorting@example.com -148 | | name/surname@example.com -149 | | xample@s.example -150 | | " "@example.org -151 | | "john..doe"@example.org -152 | | mailhost!username@example.org -153 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -154 | | user%example.com@example.org -155 | | user-@example.org -156 | | I❤️CHOCOLATE@example.com -157 | | this\ still\"not\\allowed@example.com -158 | | stellyamburrr985@example.com -159 | | Abc.123@example.com -160 | | user+mailbox/department=shipping@example.com -161 | | !#$%&'*+-/=?^_`.{|}~@example.com -162 | | "Abc@def"@example.com -163 | | "Fred\ Bloggs"@example.com -164 | | "Joe.\\Blow"@example.com""".split("\n") +160 | / r"""first +161 | | 'no need' to escape +162 | | "swap" quote style +163 | | "use' ugly triple quotes""".split("\n") | |_______________________________________^ +164 | +165 | # https://github.com/astral-sh/ruff/issues/19845 | help: Replace with list literal ℹ Safe fix -139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] -140 140 | -141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 |-r"""simple@example.com -143 |-very.common@example.com -144 |-FirstName.LastName@EasierReading.org -145 |-x@example.com -146 |-long.email-address-with-hyphens@and.subdomains.example.com -147 |-user.name+tag+sorting@example.com -148 |-name/surname@example.com -149 |-xample@s.example -150 |-" "@example.org -151 |-"john..doe"@example.org -152 |-mailhost!username@example.org -153 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -154 |-user%example.com@example.org -155 |-user-@example.org -156 |-I❤️CHOCOLATE@example.com -157 |-this\ still\"not\\allowed@example.com -158 |-stellyamburrr985@example.com -159 |-Abc.123@example.com -160 |-user+mailbox/department=shipping@example.com -161 |-!#$%&'*+-/=?^_`.{|}~@example.com -162 |-"Abc@def"@example.com -163 |-"Fred\ Bloggs"@example.com -164 |-"Joe.\\Blow"@example.com""".split("\n") - 142 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] -165 143 | -166 144 | -167 145 | r"""first +157 157 | "Joe.\\Blow"@example.com""".split("\n") +158 158 | +159 159 | +160 |-r"""first +161 |-'no need' to escape +162 |-"swap" quote style +163 |-"use' ugly triple quotes""".split("\n") + 160 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] +164 161 | +165 162 | # https://github.com/astral-sh/ruff/issues/19845 +166 163 | print("S\x1cP\x1dL\x1eI\x1fT".split()) SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:167:1 + --> SIM905.py:166:7 | -167 | / r"""first -168 | | 'no need' to escape -169 | | "swap" quote style -170 | | "use' ugly triple quotes""".split("\n") - | |_______________________________________^ -171 | -172 | # https://github.com/astral-sh/ruff/issues/19845 - | -help: Replace with list literal - -ℹ Safe fix -164 164 | "Joe.\\Blow"@example.com""".split("\n") -165 165 | -166 166 | -167 |-r"""first -168 |-'no need' to escape -169 |-"swap" quote style -170 |-"use' ugly triple quotes""".split("\n") - 167 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] -171 168 | -172 169 | # https://github.com/astral-sh/ruff/issues/19845 -173 170 | print("S\x1cP\x1dL\x1eI\x1fT".split()) - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:173:7 - | -172 | # https://github.com/astral-sh/ruff/issues/19845 -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +165 | # https://github.com/astral-sh/ruff/issues/19845 +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -170 170 | "use' ugly triple quotes""".split("\n") -171 171 | -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) - 173 |+print(["S", "P", "L", "I", "T"]) -174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -176 176 | +163 163 | "use' ugly triple quotes""".split("\n") +164 164 | +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) + 166 |+print(["S", "P", "L", "I", "T"]) +167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +169 169 | SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:174:7 + --> SIM905.py:167:7 | -172 | # https://github.com/astral-sh/ruff/issues/19845 -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +165 | # https://github.com/astral-sh/ruff/issues/19845 +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -171 171 | -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) - 174 |+print([">"]) -175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit +164 164 | +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) + 167 |+print([">"]) +168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:175:7 + --> SIM905.py:168:7 | -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -176 | -177 | # leading/trailing whitespace should not count towards maxsplit +169 | +170 | # leading/trailing whitespace should not count towards maxsplit | help: Replace with list literal ℹ Safe fix -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) - 175 |+print(["<"]) -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit -178 178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) + 168 |+print(["<"]) +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit +171 171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] SIM905 Consider using a list literal instead of `str.split` - --> SIM905.py:178:1 + --> SIM905.py:171:1 | -177 | # leading/trailing whitespace should not count towards maxsplit -178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +170 | # leading/trailing whitespace should not count towards maxsplit +171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] | help: Replace with list literal SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:172:1 + | +170 | # leading/trailing whitespace should not count towards maxsplit +171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +173 | +174 | # https://github.com/astral-sh/ruff/issues/19610 + | +help: Replace with list literal + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:175:1 + | +174 | # https://github.com/astral-sh/ruff/issues/19610 +175 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ +176 | r"" "\"".split("1") # ['"'] +177 | r"1" """ + | +help: Replace with list literal + +ℹ Safe fix +172 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 |-r"1" "\n".split("1") # [r"", "\n"] + 175 |+[r"", '\n'] # [r"", "\n"] +176 176 | r"" "\"".split("1") # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:176:1 + | +174 | # https://github.com/astral-sh/ruff/issues/19610 +175 | r"1" "\n".split("1") # [r"", "\n"] +176 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ +177 | r"1" """ +178 | """.split("1") # [r"", "\n"] + | +help: Replace with list literal + +ℹ Safe fix +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 175 | r"1" "\n".split("1") # [r"", "\n"] +176 |-r"" "\"".split("1") # ['"'] + 176 |+[r'"'] # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] +179 179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:177:1 + | +175 | r"1" "\n".split("1") # [r"", "\n"] +176 | r"" "\"".split("1") # ['"'] +177 | / r"1" """ +178 | | """.split("1") # [r"", "\n"] + | |______________^ +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | +help: Replace with list literal + +ℹ Safe fix +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 175 | r"1" "\n".split("1") # [r"", "\n"] +176 176 | r"" "\"".split("1") # ['"'] +177 |-r"1" """ +178 |-""".split("1") # [r"", "\n"] + 177 |+[r"", '\n'] # [r"", "\n"] +179 178 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:179:1 | -177 | # leading/trailing whitespace should not count towards maxsplit -178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] -179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +177 | r"1" """ +178 | """.split("1") # [r"", "\n"] +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: Replace with list literal + +ℹ Safe fix +176 176 | r"" "\"".split("1") # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] +179 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] + 179 |+['\\n\n\'"'] # ["\\n\n'\""] diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap index b7cba4c42e..809e400704 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap @@ -1367,7 +1367,7 @@ help: Replace with list literal 131 |+print([" x"]) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:132:7 @@ -1377,7 +1377,7 @@ SIM905 [*] Consider using a list literal instead of `str.split` 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 133 | -134 | # https://github.com/astral-sh/ruff/issues/19610 +134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings | help: Replace with list literal @@ -1388,281 +1388,281 @@ help: Replace with list literal 132 |-print(" x ".rsplit(sep=None, maxsplit=0)) 132 |+print([" x"]) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 135 | r"""simple@example.com SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:135:1 | -134 | # https://github.com/astral-sh/ruff/issues/19610 -135 | r"1" "\n".split("1") # [r"", "\n"] - | ^^^^^^^^^^^^^^^^^^^^ -136 | r"" "\"".split("1") # ['"'] -137 | r"1" """ +134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 | / r"""simple@example.com +136 | | very.common@example.com +137 | | FirstName.LastName@EasierReading.org +138 | | x@example.com +139 | | long.email-address-with-hyphens@and.subdomains.example.com +140 | | user.name+tag+sorting@example.com +141 | | name/surname@example.com +142 | | xample@s.example +143 | | " "@example.org +144 | | "john..doe"@example.org +145 | | mailhost!username@example.org +146 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +147 | | user%example.com@example.org +148 | | user-@example.org +149 | | I❤️CHOCOLATE@example.com +150 | | this\ still\"not\\allowed@example.com +151 | | stellyamburrr985@example.com +152 | | Abc.123@example.com +153 | | user+mailbox/department=shipping@example.com +154 | | !#$%&'*+-/=?^_`.{|}~@example.com +155 | | "Abc@def"@example.com +156 | | "Fred\ Bloggs"@example.com +157 | | "Joe.\\Blow"@example.com""".split("\n") + | |_______________________________________^ | help: Replace with list literal ℹ Safe fix 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 |-r"1" "\n".split("1") # [r"", "\n"] - 135 |+[r"", '\n'] # [r"", "\n"] -136 136 | r"" "\"".split("1") # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] +134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings +135 |-r"""simple@example.com +136 |-very.common@example.com +137 |-FirstName.LastName@EasierReading.org +138 |-x@example.com +139 |-long.email-address-with-hyphens@and.subdomains.example.com +140 |-user.name+tag+sorting@example.com +141 |-name/surname@example.com +142 |-xample@s.example +143 |-" "@example.org +144 |-"john..doe"@example.org +145 |-mailhost!username@example.org +146 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com +147 |-user%example.com@example.org +148 |-user-@example.org +149 |-I❤️CHOCOLATE@example.com +150 |-this\ still\"not\\allowed@example.com +151 |-stellyamburrr985@example.com +152 |-Abc.123@example.com +153 |-user+mailbox/department=shipping@example.com +154 |-!#$%&'*+-/=?^_`.{|}~@example.com +155 |-"Abc@def"@example.com +156 |-"Fred\ Bloggs"@example.com +157 |-"Joe.\\Blow"@example.com""".split("\n") + 135 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] +158 136 | +159 137 | +160 138 | r"""first SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:136:1 + --> SIM905.py:160:1 | -134 | # https://github.com/astral-sh/ruff/issues/19610 -135 | r"1" "\n".split("1") # [r"", "\n"] -136 | r"" "\"".split("1") # ['"'] - | ^^^^^^^^^^^^^^^^^^^ -137 | r"1" """ -138 | """.split("1") # [r"", "\n"] - | -help: Replace with list literal - -ℹ Safe fix -133 133 | -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] -136 |-r"" "\"".split("1") # ['"'] - 136 |+[r'"'] # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] -139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:137:1 - | -135 | r"1" "\n".split("1") # [r"", "\n"] -136 | r"" "\"".split("1") # ['"'] -137 | / r"1" """ -138 | | """.split("1") # [r"", "\n"] - | |______________^ -139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - | -help: Replace with list literal - -ℹ Safe fix -134 134 | # https://github.com/astral-sh/ruff/issues/19610 -135 135 | r"1" "\n".split("1") # [r"", "\n"] -136 136 | r"" "\"".split("1") # ['"'] -137 |-r"1" """ -138 |-""".split("1") # [r"", "\n"] - 137 |+[r"", '\n'] # [r"", "\n"] -139 138 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] -140 139 | -141 140 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:139:1 - | -137 | r"1" """ -138 | """.split("1") # [r"", "\n"] -139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] - | ^^^^^^^^^^^^^^^^^^^^^^^^ -140 | -141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings - | -help: Replace with list literal - -ℹ Safe fix -136 136 | r"" "\"".split("1") # ['"'] -137 137 | r"1" """ -138 138 | """.split("1") # [r"", "\n"] -139 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] - 139 |+['\\n\n\'"'] # ["\\n\n'\""] -140 140 | -141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 142 | r"""simple@example.com - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:142:1 - | -141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 | / r"""simple@example.com -143 | | very.common@example.com -144 | | FirstName.LastName@EasierReading.org -145 | | x@example.com -146 | | long.email-address-with-hyphens@and.subdomains.example.com -147 | | user.name+tag+sorting@example.com -148 | | name/surname@example.com -149 | | xample@s.example -150 | | " "@example.org -151 | | "john..doe"@example.org -152 | | mailhost!username@example.org -153 | | "very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -154 | | user%example.com@example.org -155 | | user-@example.org -156 | | I❤️CHOCOLATE@example.com -157 | | this\ still\"not\\allowed@example.com -158 | | stellyamburrr985@example.com -159 | | Abc.123@example.com -160 | | user+mailbox/department=shipping@example.com -161 | | !#$%&'*+-/=?^_`.{|}~@example.com -162 | | "Abc@def"@example.com -163 | | "Fred\ Bloggs"@example.com -164 | | "Joe.\\Blow"@example.com""".split("\n") +160 | / r"""first +161 | | 'no need' to escape +162 | | "swap" quote style +163 | | "use' ugly triple quotes""".split("\n") | |_______________________________________^ +164 | +165 | # https://github.com/astral-sh/ruff/issues/19845 | help: Replace with list literal ℹ Safe fix -139 139 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] -140 140 | -141 141 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -142 |-r"""simple@example.com -143 |-very.common@example.com -144 |-FirstName.LastName@EasierReading.org -145 |-x@example.com -146 |-long.email-address-with-hyphens@and.subdomains.example.com -147 |-user.name+tag+sorting@example.com -148 |-name/surname@example.com -149 |-xample@s.example -150 |-" "@example.org -151 |-"john..doe"@example.org -152 |-mailhost!username@example.org -153 |-"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com -154 |-user%example.com@example.org -155 |-user-@example.org -156 |-I❤️CHOCOLATE@example.com -157 |-this\ still\"not\\allowed@example.com -158 |-stellyamburrr985@example.com -159 |-Abc.123@example.com -160 |-user+mailbox/department=shipping@example.com -161 |-!#$%&'*+-/=?^_`.{|}~@example.com -162 |-"Abc@def"@example.com -163 |-"Fred\ Bloggs"@example.com -164 |-"Joe.\\Blow"@example.com""".split("\n") - 142 |+[r"simple@example.com", r"very.common@example.com", r"FirstName.LastName@EasierReading.org", r"x@example.com", r"long.email-address-with-hyphens@and.subdomains.example.com", r"user.name+tag+sorting@example.com", r"name/surname@example.com", r"xample@s.example", r'" "@example.org', r'"john..doe"@example.org', r"mailhost!username@example.org", r'"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com', r"user%example.com@example.org", r"user-@example.org", r"I❤️CHOCOLATE@example.com", r'this\ still\"not\\allowed@example.com', r"stellyamburrr985@example.com", r"Abc.123@example.com", r"user+mailbox/department=shipping@example.com", r"!#$%&'*+-/=?^_`.{|}~@example.com", r'"Abc@def"@example.com', r'"Fred\ Bloggs"@example.com', r'"Joe.\\Blow"@example.com'] -165 143 | -166 144 | -167 145 | r"""first +157 157 | "Joe.\\Blow"@example.com""".split("\n") +158 158 | +159 159 | +160 |-r"""first +161 |-'no need' to escape +162 |-"swap" quote style +163 |-"use' ugly triple quotes""".split("\n") + 160 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] +164 161 | +165 162 | # https://github.com/astral-sh/ruff/issues/19845 +166 163 | print("S\x1cP\x1dL\x1eI\x1fT".split()) SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:167:1 + --> SIM905.py:166:7 | -167 | / r"""first -168 | | 'no need' to escape -169 | | "swap" quote style -170 | | "use' ugly triple quotes""".split("\n") - | |_______________________________________^ -171 | -172 | # https://github.com/astral-sh/ruff/issues/19845 - | -help: Replace with list literal - -ℹ Safe fix -164 164 | "Joe.\\Blow"@example.com""".split("\n") -165 165 | -166 166 | -167 |-r"""first -168 |-'no need' to escape -169 |-"swap" quote style -170 |-"use' ugly triple quotes""".split("\n") - 167 |+[r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] -171 168 | -172 169 | # https://github.com/astral-sh/ruff/issues/19845 -173 170 | print("S\x1cP\x1dL\x1eI\x1fT".split()) - -SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:173:7 - | -172 | # https://github.com/astral-sh/ruff/issues/19845 -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +165 | # https://github.com/astral-sh/ruff/issues/19845 +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -170 170 | "use' ugly triple quotes""".split("\n") -171 171 | -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) - 173 |+print(["S", "P", "L", "I", "T"]) -174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -176 176 | +163 163 | "use' ugly triple quotes""".split("\n") +164 164 | +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 |-print("S\x1cP\x1dL\x1eI\x1fT".split()) + 166 |+print(["S", "P", "L", "I", "T"]) +167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +169 169 | SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:174:7 + --> SIM905.py:167:7 | -172 | # https://github.com/astral-sh/ruff/issues/19845 -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +165 | # https://github.com/astral-sh/ruff/issues/19845 +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | help: Replace with list literal ℹ Safe fix -171 171 | -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) - 174 |+print([">"]) -175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit +164 164 | +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 |-print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) + 167 |+print([">"]) +168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:175:7 + --> SIM905.py:168:7 | -173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -176 | -177 | # leading/trailing whitespace should not count towards maxsplit +169 | +170 | # leading/trailing whitespace should not count towards maxsplit | help: Replace with list literal ℹ Safe fix -172 172 | # https://github.com/astral-sh/ruff/issues/19845 -173 173 | print("S\x1cP\x1dL\x1eI\x1fT".split()) -174 174 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) -175 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) - 175 |+print(["<"]) -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit -178 178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +165 165 | # https://github.com/astral-sh/ruff/issues/19845 +166 166 | print("S\x1cP\x1dL\x1eI\x1fT".split()) +167 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) +168 |-print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) + 168 |+print(["<"]) +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit +171 171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] SIM905 [*] Consider using a list literal instead of `str.split` - --> SIM905.py:178:1 + --> SIM905.py:171:1 | -177 | # leading/trailing whitespace should not count towards maxsplit -178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +170 | # leading/trailing whitespace should not count towards maxsplit +171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] | help: Replace with list literal ℹ Safe fix -175 175 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit -178 |-" a b c d ".split(maxsplit=2) # ["a", "b", "c d "] - 178 |+["a", "b", "c d "] # ["a", "b", "c d "] -179 179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +168 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit +171 |-" a b c d ".split(maxsplit=2) # ["a", "b", "c d "] + 171 |+["a", "b", "c d "] # ["a", "b", "c d "] +172 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:172:1 + | +170 | # leading/trailing whitespace should not count towards maxsplit +171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +173 | +174 | # https://github.com/astral-sh/ruff/issues/19610 + | +help: Replace with list literal + +ℹ Safe fix +169 169 | +170 170 | # leading/trailing whitespace should not count towards maxsplit +171 171 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] +172 |-" a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] + 172 |+[" a b", "c", "d"] # [" a b", "c", "d"] +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 175 | r"1" "\n".split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:175:1 + | +174 | # https://github.com/astral-sh/ruff/issues/19610 +175 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ +176 | r"" "\"".split("1") # ['"'] +177 | r"1" """ + | +help: Replace with list literal + +ℹ Safe fix +172 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 |-r"1" "\n".split("1") # [r"", "\n"] + 175 |+[r"", '\n'] # [r"", "\n"] +176 176 | r"" "\"".split("1") # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:176:1 + | +174 | # https://github.com/astral-sh/ruff/issues/19610 +175 | r"1" "\n".split("1") # [r"", "\n"] +176 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ +177 | r"1" """ +178 | """.split("1") # [r"", "\n"] + | +help: Replace with list literal + +ℹ Safe fix +173 173 | +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 175 | r"1" "\n".split("1") # [r"", "\n"] +176 |-r"" "\"".split("1") # ['"'] + 176 |+[r'"'] # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] +179 179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:177:1 + | +175 | r"1" "\n".split("1") # [r"", "\n"] +176 | r"" "\"".split("1") # ['"'] +177 | / r"1" """ +178 | | """.split("1") # [r"", "\n"] + | |______________^ +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | +help: Replace with list literal + +ℹ Safe fix +174 174 | # https://github.com/astral-sh/ruff/issues/19610 +175 175 | r"1" "\n".split("1") # [r"", "\n"] +176 176 | r"" "\"".split("1") # ['"'] +177 |-r"1" """ +178 |-""".split("1") # [r"", "\n"] + 177 |+[r"", '\n'] # [r"", "\n"] +179 178 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:179:1 | -177 | # leading/trailing whitespace should not count towards maxsplit -178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] -179 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +177 | r"1" """ +178 | """.split("1") # [r"", "\n"] +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ | help: Replace with list literal ℹ Safe fix -176 176 | -177 177 | # leading/trailing whitespace should not count towards maxsplit -178 178 | " a b c d ".split(maxsplit=2) # ["a", "b", "c d "] -179 |-" a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] - 179 |+[" a b", "c", "d"] # [" a b", "c", "d"] +176 176 | r"" "\"".split("1") # ['"'] +177 177 | r"1" """ +178 178 | """.split("1") # [r"", "\n"] +179 |-r"\n" "\n'\"".split("1") # ["\\n\n'\""] + 179 |+['\\n\n\'"'] # ["\\n\n'\""] From 432f71180b59d79544eb2a9fa2195eae3e059ef9 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 24 Oct 2025 00:06:02 -0400 Subject: [PATCH 7/7] Fix merge conflict --- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 77 ++++++++++++++++- ...ify__tests__preview__SIM905_SIM905.py.snap | 83 ++++++++++++++++++- 2 files changed, 158 insertions(+), 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap index 2cadf0ceb9..961048deeb 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -1302,7 +1302,7 @@ help: Replace with list literal - 'no need' to escape - "swap" quote style - "use' ugly triple quotes""".split("\n") -160 + [r"first", r"'no need' to escape", r'"swap" quote style', r""""use' ugly triple quotes"""] +160 + [r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] 161 | 162 | # https://github.com/astral-sh/ruff/issues/19845 163 | print("S\x1cP\x1dL\x1eI\x1fT".split()) @@ -1394,5 +1394,80 @@ SIM905 Consider using a list literal instead of `str.split` 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] 173 | "a b".split(maxsplit=1) # ["a", "b"] | ^^^^^^^^^^^^^^^^^^^^^^^^ +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 | help: Replace with list literal + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:176:1 + | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ + | +help: Replace with list literal +173 | "a b".split(maxsplit=1) # ["a", "b"] +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 + - r"1" "\n".split("1") # [r"", "\n"] +176 + [r"", '\n'] # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:177:1 + | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + | +help: Replace with list literal +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] + - r"" "\"".split("1") # ['"'] +177 + [r'"'] # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:178:1 + | +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] +178 | / r"1" """ +179 | | """.split("1") # [r"", "\n"] + | |______________^ +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | +help: Replace with list literal +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] + - r"1" """ + - """.split("1") # [r"", "\n"] +178 + [r"", '\n'] # [r"", "\n"] +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:180:1 + | +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: Replace with list literal +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + - r"\n" "\n'\"".split("1") # ["\\n\n'\""] +180 + ['\\n\n\'"'] # ["\\n\n'\""] diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap index d477367205..d224c4581f 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap @@ -1350,7 +1350,7 @@ help: Replace with list literal - 'no need' to escape - "swap" quote style - "use' ugly triple quotes""".split("\n") -160 + [r"first", r"'no need' to escape", r'"swap" quote style', r""""use' ugly triple quotes"""] +160 + [r"first", r"'no need' to escape", r'"swap" quote style', '"use\' ugly triple quotes'] 161 | 162 | # https://github.com/astral-sh/ruff/issues/19845 163 | print("S\x1cP\x1dL\x1eI\x1fT".split()) @@ -1430,6 +1430,7 @@ help: Replace with list literal 171 + ["a", "b", "c d "] # ["a", "b", "c d "] 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] 173 | "a b".split(maxsplit=1) # ["a", "b"] +174 | SIM905 [*] Consider using a list literal instead of `str.rsplit` --> SIM905.py:172:1 @@ -1447,6 +1448,8 @@ help: Replace with list literal - " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] 172 + [" a b", "c", "d"] # [" a b", "c", "d"] 173 | "a b".split(maxsplit=1) # ["a", "b"] +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 SIM905 [*] Consider using a list literal instead of `str.split` --> SIM905.py:173:1 @@ -1455,6 +1458,8 @@ SIM905 [*] Consider using a list literal instead of `str.split` 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] 173 | "a b".split(maxsplit=1) # ["a", "b"] | ^^^^^^^^^^^^^^^^^^^^^^^^ +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 | help: Replace with list literal 170 | # leading/trailing whitespace should not count towards maxsplit @@ -1462,3 +1467,79 @@ help: Replace with list literal 172 | " a b c d ".rsplit(maxsplit=2) # [" a b", "c", "d"] - "a b".split(maxsplit=1) # ["a", "b"] 173 + ["a", "b"] # ["a", "b"] +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:176:1 + | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] + | ^^^^^^^^^^^^^^^^^^^^ +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ + | +help: Replace with list literal +173 | "a b".split(maxsplit=1) # ["a", "b"] +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 + - r"1" "\n".split("1") # [r"", "\n"] +176 + [r"", '\n'] # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:177:1 + | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] + | ^^^^^^^^^^^^^^^^^^^ +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + | +help: Replace with list literal +174 | +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] + - r"" "\"".split("1") # ['"'] +177 + [r'"'] # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:178:1 + | +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] +178 | / r"1" """ +179 | | """.split("1") # [r"", "\n"] + | |______________^ +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | +help: Replace with list literal +175 | # https://github.com/astral-sh/ruff/issues/19610 +176 | r"1" "\n".split("1") # [r"", "\n"] +177 | r"" "\"".split("1") # ['"'] + - r"1" """ + - """.split("1") # [r"", "\n"] +178 + [r"", '\n'] # [r"", "\n"] +179 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:180:1 + | +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] +180 | r"\n" "\n'\"".split("1") # ["\\n\n'\""] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: Replace with list literal +177 | r"" "\"".split("1") # ['"'] +178 | r"1" """ +179 | """.split("1") # [r"", "\n"] + - r"\n" "\n'\"".split("1") # ["\\n\n'\""] +180 + ['\\n\n\'"'] # ["\\n\n'\""]