Skip to content

Commit 1bac206

Browse files
Revert "Replace logical_lines feature with debug_assertions (#3648)" (#3708)
1 parent efc6e8c commit 1bac206

15 files changed

Lines changed: 90 additions & 89 deletions

crates/ruff/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ test-case = { workspace = true }
7474

7575
[features]
7676
default = []
77+
logical_lines = []
7778
jupyter_notebook = []

crates/ruff/src/checkers/logical_lines.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ pub fn check_logical_lines(
165165
}
166166
}
167167

168-
#[cfg(debug_assertions)]
168+
#[cfg(feature = "logical_lines")]
169169
let should_fix = autofix.into() && settings.rules.should_fix(Rule::MissingWhitespace);
170170

171-
#[cfg(not(debug_assertions))]
171+
#[cfg(not(feature = "logical_lines"))]
172172
let should_fix = false;
173173

174174
for diagnostic in
@@ -181,11 +181,11 @@ pub fn check_logical_lines(
181181
}
182182

183183
if line.flags.contains(TokenFlags::BRACKET) {
184-
#[cfg(debug_assertions)]
184+
#[cfg(feature = "logical_lines")]
185185
let should_fix =
186186
autofix.into() && settings.rules.should_fix(Rule::WhitespaceBeforeParameters);
187187

188-
#[cfg(not(debug_assertions))]
188+
#[cfg(not(feature = "logical_lines"))]
189189
let should_fix = false;
190190

191191
for diagnostic in whitespace_before_parameters(&line.tokens, should_fix) {

crates/ruff/src/codes.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,67 +26,67 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<Rule> {
2626
Some(match (linter, code) {
2727
// pycodestyle errors
2828
(Pycodestyle, "E101") => Rule::MixedSpacesAndTabs,
29-
#[cfg(debug_assertions)]
29+
#[cfg(feature = "logical_lines")]
3030
(Pycodestyle, "E111") => Rule::IndentationWithInvalidMultiple,
31-
#[cfg(debug_assertions)]
31+
#[cfg(feature = "logical_lines")]
3232
(Pycodestyle, "E112") => Rule::NoIndentedBlock,
33-
#[cfg(debug_assertions)]
33+
#[cfg(feature = "logical_lines")]
3434
(Pycodestyle, "E113") => Rule::UnexpectedIndentation,
35-
#[cfg(debug_assertions)]
35+
#[cfg(feature = "logical_lines")]
3636
(Pycodestyle, "E114") => Rule::IndentationWithInvalidMultipleComment,
37-
#[cfg(debug_assertions)]
37+
#[cfg(feature = "logical_lines")]
3838
(Pycodestyle, "E115") => Rule::NoIndentedBlockComment,
39-
#[cfg(debug_assertions)]
39+
#[cfg(feature = "logical_lines")]
4040
(Pycodestyle, "E116") => Rule::UnexpectedIndentationComment,
41-
#[cfg(debug_assertions)]
41+
#[cfg(feature = "logical_lines")]
4242
(Pycodestyle, "E117") => Rule::OverIndented,
43-
#[cfg(debug_assertions)]
43+
#[cfg(feature = "logical_lines")]
4444
(Pycodestyle, "E201") => Rule::WhitespaceAfterOpenBracket,
45-
#[cfg(debug_assertions)]
45+
#[cfg(feature = "logical_lines")]
4646
(Pycodestyle, "E202") => Rule::WhitespaceBeforeCloseBracket,
47-
#[cfg(debug_assertions)]
47+
#[cfg(feature = "logical_lines")]
4848
(Pycodestyle, "E203") => Rule::WhitespaceBeforePunctuation,
49-
#[cfg(debug_assertions)]
49+
#[cfg(feature = "logical_lines")]
5050
(Pycodestyle, "E211") => Rule::WhitespaceBeforeParameters,
51-
#[cfg(debug_assertions)]
51+
#[cfg(feature = "logical_lines")]
5252
(Pycodestyle, "E221") => Rule::MultipleSpacesBeforeOperator,
53-
#[cfg(debug_assertions)]
53+
#[cfg(feature = "logical_lines")]
5454
(Pycodestyle, "E222") => Rule::MultipleSpacesAfterOperator,
55-
#[cfg(debug_assertions)]
55+
#[cfg(feature = "logical_lines")]
5656
(Pycodestyle, "E223") => Rule::TabBeforeOperator,
57-
#[cfg(debug_assertions)]
57+
#[cfg(feature = "logical_lines")]
5858
(Pycodestyle, "E224") => Rule::TabAfterOperator,
59-
#[cfg(debug_assertions)]
59+
#[cfg(feature = "logical_lines")]
6060
(Pycodestyle, "E225") => Rule::MissingWhitespaceAroundOperator,
61-
#[cfg(debug_assertions)]
61+
#[cfg(feature = "logical_lines")]
6262
(Pycodestyle, "E226") => Rule::MissingWhitespaceAroundArithmeticOperator,
63-
#[cfg(debug_assertions)]
63+
#[cfg(feature = "logical_lines")]
6464
(Pycodestyle, "E227") => Rule::MissingWhitespaceAroundBitwiseOrShiftOperator,
65-
#[cfg(debug_assertions)]
65+
#[cfg(feature = "logical_lines")]
6666
(Pycodestyle, "E228") => Rule::MissingWhitespaceAroundModuloOperator,
67-
#[cfg(debug_assertions)]
67+
#[cfg(feature = "logical_lines")]
6868
(Pycodestyle, "E231") => Rule::MissingWhitespace,
69-
#[cfg(debug_assertions)]
69+
#[cfg(feature = "logical_lines")]
7070
(Pycodestyle, "E251") => Rule::UnexpectedSpacesAroundKeywordParameterEquals,
71-
#[cfg(debug_assertions)]
71+
#[cfg(feature = "logical_lines")]
7272
(Pycodestyle, "E252") => Rule::MissingWhitespaceAroundParameterEquals,
73-
#[cfg(debug_assertions)]
73+
#[cfg(feature = "logical_lines")]
7474
(Pycodestyle, "E261") => Rule::TooFewSpacesBeforeInlineComment,
75-
#[cfg(debug_assertions)]
75+
#[cfg(feature = "logical_lines")]
7676
(Pycodestyle, "E262") => Rule::NoSpaceAfterInlineComment,
77-
#[cfg(debug_assertions)]
77+
#[cfg(feature = "logical_lines")]
7878
(Pycodestyle, "E265") => Rule::NoSpaceAfterBlockComment,
79-
#[cfg(debug_assertions)]
79+
#[cfg(feature = "logical_lines")]
8080
(Pycodestyle, "E266") => Rule::MultipleLeadingHashesForBlockComment,
81-
#[cfg(debug_assertions)]
81+
#[cfg(feature = "logical_lines")]
8282
(Pycodestyle, "E271") => Rule::MultipleSpacesAfterKeyword,
83-
#[cfg(debug_assertions)]
83+
#[cfg(feature = "logical_lines")]
8484
(Pycodestyle, "E272") => Rule::MultipleSpacesBeforeKeyword,
85-
#[cfg(debug_assertions)]
85+
#[cfg(feature = "logical_lines")]
8686
(Pycodestyle, "E273") => Rule::TabAfterKeyword,
87-
#[cfg(debug_assertions)]
87+
#[cfg(feature = "logical_lines")]
8888
(Pycodestyle, "E274") => Rule::TabBeforeKeyword,
89-
#[cfg(debug_assertions)]
89+
#[cfg(feature = "logical_lines")]
9090
(Pycodestyle, "E275") => Rule::MissingWhitespaceAfterKeyword,
9191
(Pycodestyle, "E401") => Rule::MultipleImportsOnOneLine,
9292
(Pycodestyle, "E402") => Rule::ModuleImportNotAtTopOfFile,

crates/ruff/src/registry.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,67 @@ pub use rule_set::{RuleSet, RuleSetIterator};
1414
ruff_macros::register_rules!(
1515
// pycodestyle errors
1616
rules::pycodestyle::rules::MixedSpacesAndTabs,
17-
#[cfg(debug_assertions)]
17+
#[cfg(feature = "logical_lines")]
1818
rules::pycodestyle::rules::IndentationWithInvalidMultiple,
19-
#[cfg(debug_assertions)]
19+
#[cfg(feature = "logical_lines")]
2020
rules::pycodestyle::rules::NoIndentedBlock,
21-
#[cfg(debug_assertions)]
21+
#[cfg(feature = "logical_lines")]
2222
rules::pycodestyle::rules::UnexpectedIndentation,
23-
#[cfg(debug_assertions)]
23+
#[cfg(feature = "logical_lines")]
2424
rules::pycodestyle::rules::IndentationWithInvalidMultipleComment,
25-
#[cfg(debug_assertions)]
25+
#[cfg(feature = "logical_lines")]
2626
rules::pycodestyle::rules::NoIndentedBlockComment,
27-
#[cfg(debug_assertions)]
27+
#[cfg(feature = "logical_lines")]
2828
rules::pycodestyle::rules::UnexpectedIndentationComment,
29-
#[cfg(debug_assertions)]
29+
#[cfg(feature = "logical_lines")]
3030
rules::pycodestyle::rules::OverIndented,
31-
#[cfg(debug_assertions)]
31+
#[cfg(feature = "logical_lines")]
3232
rules::pycodestyle::rules::WhitespaceAfterOpenBracket,
33-
#[cfg(debug_assertions)]
33+
#[cfg(feature = "logical_lines")]
3434
rules::pycodestyle::rules::WhitespaceBeforeCloseBracket,
35-
#[cfg(debug_assertions)]
35+
#[cfg(feature = "logical_lines")]
3636
rules::pycodestyle::rules::WhitespaceBeforePunctuation,
37-
#[cfg(debug_assertions)]
37+
#[cfg(feature = "logical_lines")]
3838
rules::pycodestyle::rules::MultipleSpacesBeforeOperator,
39-
#[cfg(debug_assertions)]
39+
#[cfg(feature = "logical_lines")]
4040
rules::pycodestyle::rules::MultipleSpacesAfterOperator,
41-
#[cfg(debug_assertions)]
41+
#[cfg(feature = "logical_lines")]
4242
rules::pycodestyle::rules::TabBeforeOperator,
43-
#[cfg(debug_assertions)]
43+
#[cfg(feature = "logical_lines")]
4444
rules::pycodestyle::rules::TabAfterOperator,
45-
#[cfg(debug_assertions)]
45+
#[cfg(feature = "logical_lines")]
4646
rules::pycodestyle::rules::TooFewSpacesBeforeInlineComment,
47-
#[cfg(debug_assertions)]
47+
#[cfg(feature = "logical_lines")]
4848
rules::pycodestyle::rules::NoSpaceAfterInlineComment,
49-
#[cfg(debug_assertions)]
49+
#[cfg(feature = "logical_lines")]
5050
rules::pycodestyle::rules::NoSpaceAfterBlockComment,
51-
#[cfg(debug_assertions)]
51+
#[cfg(feature = "logical_lines")]
5252
rules::pycodestyle::rules::MultipleLeadingHashesForBlockComment,
53-
#[cfg(debug_assertions)]
53+
#[cfg(feature = "logical_lines")]
5454
rules::pycodestyle::rules::MultipleSpacesAfterKeyword,
55-
#[cfg(debug_assertions)]
55+
#[cfg(feature = "logical_lines")]
5656
rules::pycodestyle::rules::MissingWhitespace,
57-
#[cfg(debug_assertions)]
57+
#[cfg(feature = "logical_lines")]
5858
rules::pycodestyle::rules::MissingWhitespaceAfterKeyword,
59-
#[cfg(debug_assertions)]
59+
#[cfg(feature = "logical_lines")]
6060
rules::pycodestyle::rules::MultipleSpacesBeforeKeyword,
61-
#[cfg(debug_assertions)]
61+
#[cfg(feature = "logical_lines")]
6262
rules::pycodestyle::rules::MissingWhitespaceAroundOperator,
63-
#[cfg(debug_assertions)]
63+
#[cfg(feature = "logical_lines")]
6464
rules::pycodestyle::rules::MissingWhitespaceAroundArithmeticOperator,
65-
#[cfg(debug_assertions)]
65+
#[cfg(feature = "logical_lines")]
6666
rules::pycodestyle::rules::MissingWhitespaceAroundBitwiseOrShiftOperator,
67-
#[cfg(debug_assertions)]
67+
#[cfg(feature = "logical_lines")]
6868
rules::pycodestyle::rules::MissingWhitespaceAroundModuloOperator,
69-
#[cfg(debug_assertions)]
69+
#[cfg(feature = "logical_lines")]
7070
rules::pycodestyle::rules::TabAfterKeyword,
71-
#[cfg(debug_assertions)]
71+
#[cfg(feature = "logical_lines")]
7272
rules::pycodestyle::rules::UnexpectedSpacesAroundKeywordParameterEquals,
73-
#[cfg(debug_assertions)]
73+
#[cfg(feature = "logical_lines")]
7474
rules::pycodestyle::rules::MissingWhitespaceAroundParameterEquals,
75-
#[cfg(debug_assertions)]
75+
#[cfg(feature = "logical_lines")]
7676
rules::pycodestyle::rules::WhitespaceBeforeParameters,
77-
#[cfg(debug_assertions)]
77+
#[cfg(feature = "logical_lines")]
7878
rules::pycodestyle::rules::TabBeforeKeyword,
7979
rules::pycodestyle::rules::MultipleImportsOnOneLine,
8080
rules::pycodestyle::rules::ModuleImportNotAtTopOfFile,
@@ -906,7 +906,7 @@ impl Rule {
906906
Rule::IOError => LintSource::Io,
907907
Rule::UnsortedImports | Rule::MissingRequiredImport => LintSource::Imports,
908908
Rule::ImplicitNamespacePackage | Rule::InvalidModuleName => LintSource::Filesystem,
909-
#[cfg(debug_assertions)]
909+
#[cfg(feature = "logical_lines")]
910910
Rule::IndentationWithInvalidMultiple
911911
| Rule::IndentationWithInvalidMultipleComment
912912
| Rule::MissingWhitespace

crates/ruff/src/rules/pycodestyle/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mod tests {
7979
Ok(())
8080
}
8181

82-
#[cfg(debug_assertions)]
82+
#[cfg(feature = "logical_lines")]
8383
#[test_case(Rule::IndentationWithInvalidMultiple, Path::new("E11.py"))]
8484
#[test_case(Rule::IndentationWithInvalidMultipleComment, Path::new("E11.py"))]
8585
#[test_case(Rule::MultipleLeadingHashesForBlockComment, Path::new("E26.py"))]

crates/ruff/src/rules/pycodestyle/rules/extraneous_whitespace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static EXTRANEOUS_WHITESPACE_REGEX: Lazy<Regex> =
106106
Lazy::new(|| Regex::new(r"([\[({][ \t]|[ \t][]}),;:])").unwrap());
107107

108108
/// E201, E202, E203
109-
#[cfg(debug_assertions)]
109+
#[cfg(feature = "logical_lines")]
110110
pub fn extraneous_whitespace(line: &str) -> Vec<(usize, DiagnosticKind)> {
111111
let mut diagnostics = vec![];
112112
for line_match in EXTRANEOUS_WHITESPACE_REGEX.captures_iter(line) {
@@ -127,7 +127,7 @@ pub fn extraneous_whitespace(line: &str) -> Vec<(usize, DiagnosticKind)> {
127127
diagnostics
128128
}
129129

130-
#[cfg(not(debug_assertions))]
130+
#[cfg(not(feature = "logical_lines"))]
131131
pub fn extraneous_whitespace(_line: &str) -> Vec<(usize, DiagnosticKind)> {
132132
vec![]
133133
}

crates/ruff/src/rules/pycodestyle/rules/indentation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Violation for OverIndented {
230230
}
231231

232232
/// E111, E114, E112, E113, E115, E116, E117
233-
#[cfg(debug_assertions)]
233+
#[cfg(feature = "logical_lines")]
234234
pub fn indentation(
235235
logical_line: &LogicalLine,
236236
prev_logical_line: Option<&LogicalLine>,
@@ -284,7 +284,7 @@ pub fn indentation(
284284
diagnostics
285285
}
286286

287-
#[cfg(not(debug_assertions))]
287+
#[cfg(not(feature = "logical_lines"))]
288288
pub fn indentation(
289289
_logical_line: &LogicalLine,
290290
_prev_logical_line: Option<&LogicalLine>,

crates/ruff/src/rules/pycodestyle/rules/missing_whitespace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl AlwaysAutofixableViolation for MissingWhitespace {
2828
}
2929

3030
/// E231
31-
#[cfg(debug_assertions)]
31+
#[cfg(feature = "logical_lines")]
3232
pub fn missing_whitespace(
3333
line: &str,
3434
row: usize,
@@ -86,7 +86,7 @@ pub fn missing_whitespace(
8686
diagnostics
8787
}
8888

89-
#[cfg(not(debug_assertions))]
89+
#[cfg(not(feature = "logical_lines"))]
9090
pub fn missing_whitespace(
9191
_line: &str,
9292
_row: usize,

crates/ruff/src/rules/pycodestyle/rules/missing_whitespace_after_keyword.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Violation for MissingWhitespaceAfterKeyword {
2020
}
2121

2222
/// E275
23-
#[cfg(debug_assertions)]
23+
#[cfg(feature = "logical_lines")]
2424
pub fn missing_whitespace_after_keyword(
2525
tokens: &[(Location, &Tok, Location)],
2626
) -> Vec<(Location, DiagnosticKind)> {
@@ -43,7 +43,7 @@ pub fn missing_whitespace_after_keyword(
4343
diagnostics
4444
}
4545

46-
#[cfg(not(debug_assertions))]
46+
#[cfg(not(feature = "logical_lines"))]
4747
pub fn missing_whitespace_after_keyword(
4848
_tokens: &[(Location, &Tok, Location)],
4949
) -> Vec<(Location, DiagnosticKind)> {

crates/ruff/src/rules/pycodestyle/rules/missing_whitespace_around_operator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Violation for MissingWhitespaceAroundModuloOperator {
5757
}
5858

5959
/// E225, E226, E227, E228
60-
#[cfg(debug_assertions)]
60+
#[cfg(feature = "logical_lines")]
6161
#[allow(clippy::if_same_then_else)]
6262
pub fn missing_whitespace_around_operator(
6363
tokens: &[(Location, &Tok, Location)],
@@ -188,7 +188,7 @@ pub fn missing_whitespace_around_operator(
188188
diagnostics
189189
}
190190

191-
#[cfg(not(debug_assertions))]
191+
#[cfg(not(feature = "logical_lines"))]
192192
pub fn missing_whitespace_around_operator(
193193
_tokens: &[(Location, &Tok, Location)],
194194
) -> Vec<(Location, DiagnosticKind)> {

0 commit comments

Comments
 (0)