Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions crates/ruff_linter/src/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,6 @@ pub(crate) const fn is_allow_nested_roots_enabled(settings: &LinterSettings) ->
settings.preview.is_enabled()
}

// https://github.com/astral-sh/ruff/pull/18208
pub(crate) const fn is_multiple_with_statements_fix_safe_enabled(
settings: &LinterSettings,
) -> bool {
settings.preview.is_enabled()
}

// https://github.com/astral-sh/ruff/pull/18400
pub(crate) const fn is_ignore_init_files_in_useless_alias_enabled(
settings: &LinterSettings,
Expand Down
1 change: 0 additions & 1 deletion crates/ruff_linter/src/rules/flake8_simplify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ mod tests {
Ok(())
}

#[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!(
Expand Down
14 changes: 1 addition & 13 deletions crates/ruff_linter/src/rules/flake8_simplify/rules/ast_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::fix_with;
use crate::Fix;
use crate::checkers::ast::Checker;
use crate::fix::edits::fits;
use crate::preview::is_multiple_with_statements_fix_safe_enabled;
use crate::{FixAvailability, Violation};

/// ## What it does
Expand Down Expand Up @@ -45,15 +44,8 @@ use crate::{FixAvailability, Violation};
/// pass
/// ```
///
/// ## Fix safety
///
/// This fix is marked as always unsafe unless [preview] mode is enabled, in which case it is always
/// marked as safe. Note that the fix is unavailable if it would remove comments (in either case).
///
/// ## References
/// - [Python documentation: The `with` statement](https://docs.python.org/3/reference/compound_stmts.html#the-with-statement)
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[derive(ViolationMetadata)]
pub(crate) struct MultipleWithStatements;

Expand Down Expand Up @@ -195,11 +187,7 @@ pub(crate) fn multiple_with_statements(
checker.settings().tab_size,
)
}) {
if is_multiple_with_statements_fix_safe_enabled(checker.settings()) {
Ok(Some(Fix::safe_edit(edit)))
} else {
Ok(Some(Fix::unsafe_edit(edit)))
}
Ok(Some(Fix::safe_edit(edit)))
} else {
Ok(None)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ help: Combine `with` statements
4 |
5 | # SIM117
6 | with A():
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:7:1
Expand All @@ -46,7 +45,6 @@ help: Combine `with` statements
10 |
11 | # SIM117
12 | with A() as a:
note: This is an unsafe fix and may change runtime behavior

SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:13:1
Expand Down Expand Up @@ -84,7 +82,6 @@ help: Combine `with` statements
22 |
23 | # OK
24 | with A() as a:
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:47:1
Expand All @@ -107,7 +104,6 @@ help: Combine `with` statements
49 |
50 | while True:
51 | # SIM117
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:53:5
Expand Down Expand Up @@ -144,7 +140,6 @@ help: Combine `with` statements
64 | "this for some reason")
65 |
66 | # SIM117
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:68:1
Expand All @@ -171,7 +166,6 @@ help: Combine `with` statements
73 |
74 | # SIM117
75 | with A() as a:
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:76:1
Expand Down Expand Up @@ -203,7 +197,6 @@ help: Combine `with` statements
81 |
82 | # SIM117
83 | with (
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:84:1
Expand Down Expand Up @@ -237,7 +230,6 @@ help: Combine `with` statements
90 |
91 | # SIM117 (auto-fixable)
92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a:
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:95:1
Expand All @@ -260,7 +252,6 @@ help: Combine `with` statements
97 |
98 | # SIM117 (not auto-fixable too long)
99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a:
note: This is an unsafe fix and may change runtime behavior

SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:100:1
Expand Down Expand Up @@ -319,7 +310,6 @@ help: Combine `with` statements
136 |
137 | # Allow cascading for some statements.
138 | import anyio
note: This is an unsafe fix and may change runtime behavior

SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements
--> SIM117.py:163:1
Expand All @@ -339,4 +329,3 @@ help: Combine `with` statements
- pass
163 + async with asyncio.timeout(1), A(), B():
164 + pass
note: This is an unsafe fix and may change runtime behavior
Loading
Loading