From 2e1d6623cd5ba3e8ddbffee4df76e3ff0359b903 Mon Sep 17 00:00:00 2001 From: Frazer McLean Date: Fri, 15 Aug 2025 21:18:06 +0200 Subject: [PATCH] [`flake8-simplify`] Implement fix for `maxsplit` without separator (`SIM905`) (#19851) **Stacked on top of #19849; diff will include that PR until it is merged.** --- ## Summary As part of #19849, I noticed this fix could be implemented. ## Test Plan Tests added based on CPython behaviour. --- .../test/fixtures/flake8_simplify/SIM905.py | 4 + crates/ruff_linter/src/preview.rs | 5 + .../src/rules/flake8_simplify/mod.rs | 1 + .../rules/split_static_string.rs | 38 +- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 28 + ...ify__tests__preview__SIM905_SIM905.py.snap | 1580 +++++++++++++++++ 6 files changed, 1650 insertions(+), 6 deletions(-) create mode 100644 crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap 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 1981b422ad..6b954b530b 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM905.py @@ -166,3 +166,7 @@ r"""first print("S\x1cP\x1dL\x1eI\x1fT".split()) print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) 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"] diff --git a/crates/ruff_linter/src/preview.rs b/crates/ruff_linter/src/preview.rs index 3bcc8721fb..73edcbf71d 100644 --- a/crates/ruff_linter/src/preview.rs +++ b/crates/ruff_linter/src/preview.rs @@ -230,3 +230,8 @@ pub(crate) const fn is_add_future_annotations_imports_enabled(settings: &LinterS pub(crate) const fn is_trailing_comma_type_params_enabled(settings: &LinterSettings) -> bool { settings.preview.is_enabled() } + +// https://github.com/astral-sh/ruff/pull/19851 +pub(crate) const fn is_maxsplit_without_separator_fix_enabled(settings: &LinterSettings) -> bool { + settings.preview.is_enabled() +} diff --git a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs index 1fd42b3450..d3ac85a8fb 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs @@ -60,6 +60,7 @@ mod tests { } #[test_case(Rule::MultipleWithStatements, Path::new("SIM117.py"))] + #[test_case(Rule::SplitStaticString, Path::new("SIM905.py"))] fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> { let snapshot = format!( "preview__{}_{}", 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 367f2b5b34..c8a6f46e03 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 @@ -9,6 +9,8 @@ use ruff_python_ast::{ use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; +use crate::preview::is_maxsplit_without_separator_fix_enabled; +use crate::settings::LinterSettings; use crate::{Applicability, Edit, Fix, FixAvailability, Violation}; /// ## What it does @@ -84,7 +86,9 @@ pub(crate) fn split_static_string( let sep_arg = arguments.find_argument_value("sep", 0); let split_replacement = if let Some(sep) = sep_arg { match sep { - Expr::NoneLiteral(_) => split_default(str_value, maxsplit_value, direction), + Expr::NoneLiteral(_) => { + split_default(str_value, maxsplit_value, direction, checker.settings()) + } Expr::StringLiteral(sep_value) => { let sep_value_str = sep_value.value.to_str(); Some(split_sep( @@ -100,7 +104,7 @@ pub(crate) fn split_static_string( } } } else { - split_default(str_value, maxsplit_value, direction) + split_default(str_value, maxsplit_value, direction, checker.settings()) }; let mut diagnostic = checker.report_diagnostic(SplitStaticString, call.range()); @@ -174,6 +178,7 @@ fn split_default( str_value: &StringLiteralValue, max_split: i32, direction: Direction, + settings: &LinterSettings, ) -> Option { // From the Python documentation: // > If sep is not specified or is None, a different splitting algorithm is applied: runs of @@ -185,10 +190,31 @@ fn split_default( let string_val = str_value.to_str(); match max_split.cmp(&0) { Ordering::Greater => { - // Autofix for `maxsplit` without separator not yet implemented, as - // `split_whitespace().remainder()` is not stable: - // https://doc.rust-lang.org/std/str/struct.SplitWhitespace.html#method.remainder - None + if !is_maxsplit_without_separator_fix_enabled(settings) { + return None; + } + let Ok(max_split) = usize::try_from(max_split) else { + return None; + }; + let list_items: Vec<&str> = if direction == Direction::Left { + string_val + .trim_start_matches(py_unicode_is_whitespace) + .splitn(max_split + 1, py_unicode_is_whitespace) + .filter(|s| !s.is_empty()) + .collect() + } else { + let mut items: Vec<&str> = string_val + .trim_end_matches(py_unicode_is_whitespace) + .rsplitn(max_split + 1, py_unicode_is_whitespace) + .filter(|s| !s.is_empty()) + .collect(); + items.reverse(); + items + }; + Some(construct_replacement( + &list_items, + str_value.first_literal_flags(), + )) } Ordering::Equal => { // Behavior for maxsplit = 0 when sep is None: 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 84feb52b7d..bda8037b7f 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 @@ -1439,6 +1439,7 @@ help: Replace with list literal 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:167:7 @@ -1458,6 +1459,8 @@ help: Replace with list literal 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:168:7 @@ -1466,6 +1469,8 @@ SIM905 [*] Consider using a list literal instead of `str.split` 167 | print("\x1c\x1d\x1e\x1f>".split(maxsplit=0)) 168 | print("<\x1c\x1d\x1e\x1f".rsplit(maxsplit=0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +169 | +170 | # leading/trailing whitespace should not count towards maxsplit | help: Replace with list literal @@ -1475,3 +1480,26 @@ help: Replace with list literal 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:171: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"] + | +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"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: Replace with list literal 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 new file mode 100644 index 0000000000..e45eabb21c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM905_SIM905.py.snap @@ -0,0 +1,1580 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:6:1 + | + 5 | # positives + 6 | / """ + 7 | | itemA + 8 | | itemB + 9 | | itemC +10 | | """.split() + | |___________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:12:1 + | +10 | """.split() +11 | +12 | "a,b,c,d".split(",") + | ^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:13:1 + | +12 | "a,b,c,d".split(",") +13 | "a,b,c,d".split(None) + | ^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:14:1 + | +12 | "a,b,c,d".split(",") +13 | "a,b,c,d".split(None) +14 | "a,b,c,d".split(",", 1) + | ^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:15:1 + | +13 | "a,b,c,d".split(None) +14 | "a,b,c,d".split(",", 1) +15 | "a,b,c,d".split(None, 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^ +16 | "a,b,c,d".split(sep=",") +17 | "a,b,c,d".split(sep=None) + | +help: Replace with list literal + +ℹ Safe fix +12 12 | "a,b,c,d".split(",") +13 13 | "a,b,c,d".split(None) +14 14 | "a,b,c,d".split(",", 1) +15 |-"a,b,c,d".split(None, 1) + 15 |+["a,b,c,d"] +16 16 | "a,b,c,d".split(sep=",") +17 17 | "a,b,c,d".split(sep=None) +18 18 | "a,b,c,d".split(sep=",", maxsplit=1) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:16:1 + | +14 | "a,b,c,d".split(",", 1) +15 | "a,b,c,d".split(None, 1) +16 | "a,b,c,d".split(sep=",") + | ^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:17:1 + | +15 | "a,b,c,d".split(None, 1) +16 | "a,b,c,d".split(sep=",") +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) + | +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:18:1 + | +16 | "a,b,c,d".split(sep=",") +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) +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:19:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 | "a,b,c,d".split(maxsplit=1, sep=None) + | +help: Replace with list literal + +ℹ Safe fix +16 16 | "a,b,c,d".split(sep=",") +17 17 | "a,b,c,d".split(sep=None) +18 18 | "a,b,c,d".split(sep=",", maxsplit=1) +19 |-"a,b,c,d".split(sep=None, maxsplit=1) + 19 |+["a,b,c,d"] +20 20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 22 | "a,b,c,d".split(",", maxsplit=1) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:20:1 + | +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=",") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:21:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +22 | "a,b,c,d".split(",", maxsplit=1) +23 | "a,b,c,d".split(None, maxsplit=1) + | +help: Replace with list literal + +ℹ Safe fix +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=",") +21 |-"a,b,c,d".split(maxsplit=1, sep=None) + 21 |+["a,b,c,d"] +22 22 | "a,b,c,d".split(",", maxsplit=1) +23 23 | "a,b,c,d".split(None, maxsplit=1) +24 24 | "a,b,c,d".split(maxsplit=1) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:22:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:23:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +24 | "a,b,c,d".split(maxsplit=1) +25 | "a,b,c,d".split(maxsplit=1.0) + | +help: Replace with list literal + +ℹ Safe fix +20 20 | "a,b,c,d".split(maxsplit=1, sep=",") +21 21 | "a,b,c,d".split(maxsplit=1, sep=None) +22 22 | "a,b,c,d".split(",", maxsplit=1) +23 |-"a,b,c,d".split(None, maxsplit=1) + 23 |+["a,b,c,d"] +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) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:24:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +25 | "a,b,c,d".split(maxsplit=1.0) +26 | "a,b,c,d".split(maxsplit=1) + | +help: Replace with list literal + +ℹ Safe fix +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) +24 |-"a,b,c,d".split(maxsplit=1) + 24 |+["a,b,c,d"] +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) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:26:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") + | +help: Replace with list literal + +ℹ Safe fix +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) +26 |-"a,b,c,d".split(maxsplit=1) + 26 |+["a,b,c,d"] +27 27 | "a,b,c,d".split(maxsplit=0) +28 28 | "VERB AUX PRON ADP DET".split(" ") +29 29 | ' 1 2 3 '.split() + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:27:1 + | +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) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:28:1 + | +26 | "a,b,c,d".split(maxsplit=1) +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:29:1 + | +27 | "a,b,c,d".split(maxsplit=0) +28 | "VERB AUX PRON ADP DET".split(" ") +29 | ' 1 2 3 '.split() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:30:1 + | +28 | "VERB AUX PRON ADP DET".split(" ") +29 | ' 1 2 3 '.split() +30 | '1<>2<>3<4'.split('<>') + | ^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:32:1 + | +30 | '1<>2<>3<4'.split('<>') +31 | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:33:1 + | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 | "".split() # [] + | ^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:34:1 + | +32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] +33 | "".split() # [] +34 | / """ +35 | | """.split() # [] + | |___________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:36:1 + | +34 | """ +35 | """.split() # [] +36 | " ".split() # [] + | ^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:37:1 + | +35 | """.split() # [] +36 | " ".split() # [] +37 | "/abc/".split() # ["/abc/"] + | ^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:38:2 + | +36 | " ".split() # [] +37 | "/abc/".split() # ["/abc/"] +38 | ("a,b,c" + | __^ +39 | | # comment +40 | | .split() + | |________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:42:2 + | +40 | .split() +41 | ) # ["a,b,c"] +42 | ("a,b,c" + | __^ +43 | | # comment1 +44 | | .split(",") + | |___________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:46:2 + | +44 | .split(",") +45 | ) # ["a", "b", "c"] +46 | ("a," + | __^ +47 | | # comment +48 | | "b," +49 | | "c" +50 | | .split(",") + | |___________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:53:1 + | +51 | ) # ["a", "b", "c"] +52 | +53 | / "hello "\ +54 | | "world".split() + | |___________________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:58:1 + | +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"] +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:59:1 + | +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"] + | ^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:60:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:61:1 + | +59 | r"a \n b".split() # [r"a", r"\n", r"b"] +60 | ("a " "b").split() # ["a", "b"] +61 | "a " "b".split() # ["a", "b"] + | ^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:62:1 + | +60 | ("a " "b").split() # ["a", "b"] +61 | "a " "b".split() # ["a", "b"] +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"] + | +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:63:1 + | +61 | "a " "b".split() # ["a", "b"] +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"] +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:64:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:65:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:66:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:67:1 + | +65 | r"\n " u"\n".split() # [r"\n"] +66 | r"\n " "\n".split() # [r"\n"] +67 | "a " r"\n".split() # ["a", "\\n"] + | ^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:69:1 + | +67 | "a " r"\n".split() # ["a", "\\n"] +68 | +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"] + | +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:70:1 + | +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"] +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:71:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:72:1 + | +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"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:103:1 + | +102 | # another positive demonstrating quote preservation +103 | / """ +104 | | "itemA" +105 | | 'itemB' +106 | | '''itemC''' +107 | | "'itemD'" +108 | | """.split() + | |___________^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:111:7 + | +110 | # https://github.com/astral-sh/ruff/issues/18042 +111 | print("a,b".rsplit(",")) + | ^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:112:7 + | +110 | # https://github.com/astral-sh/ruff/issues/18042 +111 | print("a,b".rsplit(",")) +112 | print("a,b,c".rsplit(",", 1)) + | ^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:116:7 + | +114 | # https://github.com/astral-sh/ruff/issues/18069 +115 | +116 | print("".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:117:7 + | +116 | print("".split(maxsplit=0)) +117 | print("".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:118:7 + | +116 | print("".split(maxsplit=0)) +117 | print("".split(sep=None, maxsplit=0)) +118 | print(" ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:119:7 + | +117 | print("".split(sep=None, maxsplit=0)) +118 | print(" ".split(maxsplit=0)) +119 | print(" ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:120:7 + | +118 | print(" ".split(maxsplit=0)) +119 | print(" ".split(sep=None, maxsplit=0)) +120 | print(" x ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:121:7 + | +119 | print(" ".split(sep=None, maxsplit=0)) +120 | print(" x ".split(maxsplit=0)) +121 | print(" x ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:122:7 + | +120 | print(" x ".split(maxsplit=0)) +121 | print(" x ".split(sep=None, maxsplit=0)) +122 | print(" x ".split(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:123:7 + | +121 | print(" x ".split(sep=None, maxsplit=0)) +122 | print(" x ".split(maxsplit=0)) +123 | print(" x ".split(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:124:7 + | +122 | print(" x ".split(maxsplit=0)) +123 | print(" x ".split(sep=None, maxsplit=0)) +124 | print("".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:125:7 + | +123 | print(" x ".split(sep=None, maxsplit=0)) +124 | print("".rsplit(maxsplit=0)) +125 | print("".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:126:7 + | +124 | print("".rsplit(maxsplit=0)) +125 | print("".rsplit(sep=None, maxsplit=0)) +126 | print(" ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:127:7 + | +125 | print("".rsplit(sep=None, maxsplit=0)) +126 | print(" ".rsplit(maxsplit=0)) +127 | print(" ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:128:7 + | +126 | print(" ".rsplit(maxsplit=0)) +127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:129:7 + | +127 | print(" ".rsplit(sep=None, maxsplit=0)) +128 | print(" x ".rsplit(maxsplit=0)) +129 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:130:7 + | +128 | print(" x ".rsplit(maxsplit=0)) +129 | print(" x ".rsplit(maxsplit=0)) +130 | print(" x ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +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 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:131:7 + | +129 | print(" x ".rsplit(maxsplit=0)) +130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 | print(" x ".rsplit(maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +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/19581 - embedded quotes in raw strings + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:132:7 + | +130 | print(" x ".rsplit(sep=None, maxsplit=0)) +131 | print(" x ".rsplit(maxsplit=0)) +132 | print(" x ".rsplit(sep=None, maxsplit=0)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +133 | +134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings + | +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/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/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/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:160:1 + | +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 +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()) + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:166: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)) +168 | 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 | + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:167: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)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +168 | 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 + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:168: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)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +169 | +170 | # 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 "] + +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:171: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"] + | +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"] + +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"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +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"]