Skip to content

Commit 50fa555

Browse files
authored
[syntax errors] Stabilize version-specific unsupported syntax errors (#18522)
1 parent 3bd775f commit 50fa555

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

crates/ruff/tests/lint.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5436,14 +5436,15 @@ match 2:
54365436
print("it's one")
54375437
"#
54385438
),
5439-
@r"
5440-
success: true
5441-
exit_code: 0
5439+
@r###"
5440+
success: false
5441+
exit_code: 1
54425442
----- stdout -----
5443-
All checks passed!
5443+
test.py:2:1: SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)
5444+
Found 1 error.
54445445
54455446
----- stderr -----
5446-
"
5447+
"###
54475448
);
54485449

54495450
// syntax error on 3.9 with preview

crates/ruff_linter/src/linter.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::fix::{FixResult, fix_file};
3030
use crate::message::Message;
3131
use crate::noqa::add_noqa;
3232
use crate::package::PackageRoot;
33-
use crate::preview::{is_py314_support_enabled, is_unsupported_syntax_enabled};
33+
use crate::preview::is_py314_support_enabled;
3434
use crate::registry::{AsRule, Rule, RuleSet};
3535
#[cfg(any(feature = "test-rules", test))]
3636
use crate::rules::ruff::rules::test_rules::{self, TEST_RULES, TestRule};
@@ -447,11 +447,7 @@ pub fn check_path(
447447
}
448448
}
449449

450-
let syntax_errors = if is_unsupported_syntax_enabled(settings) {
451-
parsed.unsupported_syntax_errors()
452-
} else {
453-
&[]
454-
};
450+
let syntax_errors = parsed.unsupported_syntax_errors();
455451

456452
diagnostics_to_messages(
457453
diagnostics,

crates/ruff_linter/src/preview.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ pub(crate) const fn is_semantic_errors_enabled(settings: &LinterSettings) -> boo
1313
settings.preview.is_enabled()
1414
}
1515

16-
// https://github.com/astral-sh/ruff/pull/16429
17-
pub(crate) const fn is_unsupported_syntax_enabled(settings: &LinterSettings) -> bool {
18-
settings.preview.is_enabled()
19-
}
20-
2116
pub(crate) const fn is_py314_support_enabled(settings: &LinterSettings) -> bool {
2217
settings.preview.is_enabled()
2318
}

crates/ruff_wasm/tests/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn syntax_error() {
6565
fn unsupported_syntax_error() {
6666
check!(
6767
"match 2:\n case 1: ...",
68-
r#"{"preview": true, "target-version": "py39"}"#,
68+
r#"{"target-version": "py39"}"#,
6969
[ExpandedMessage {
7070
code: None,
7171
message: "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)".to_string(),

0 commit comments

Comments
 (0)