File tree 3 files changed +15
-3
lines changed
3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,12 @@ pub(crate) fn check(
172
172
)
173
173
} ) ;
174
174
175
+ let unsupported_syntax_errors = if settings. linter . preview . is_enabled ( ) {
176
+ parsed. unsupported_syntax_errors ( )
177
+ } else {
178
+ & [ ]
179
+ } ;
180
+
175
181
let lsp_diagnostics = lsp_diagnostics. chain (
176
182
show_syntax_errors
177
183
. then ( || {
@@ -186,7 +192,7 @@ pub(crate) fn check(
186
192
encoding,
187
193
)
188
194
} )
189
- . chain ( parsed . unsupported_syntax_errors ( ) . iter ( ) . map ( |error| {
195
+ . chain ( unsupported_syntax_errors. iter ( ) . map ( |error| {
190
196
unsupported_syntax_error_to_lsp_diagnostic (
191
197
error,
192
198
& source_kind,
Original file line number Diff line number Diff line change @@ -205,6 +205,12 @@ impl Workspace {
205
205
206
206
let source_code = locator. to_source_code ( ) ;
207
207
208
+ let unsupported_syntax_errors = if self . settings . linter . preview . is_enabled ( ) {
209
+ parsed. unsupported_syntax_errors ( )
210
+ } else {
211
+ & [ ]
212
+ } ;
213
+
208
214
let messages: Vec < ExpandedMessage > = diagnostics
209
215
. into_iter ( )
210
216
. map ( |diagnostic| {
@@ -242,7 +248,7 @@ impl Workspace {
242
248
fix : None ,
243
249
}
244
250
} ) )
245
- . chain ( parsed . unsupported_syntax_errors ( ) . iter ( ) . map ( |error| {
251
+ . chain ( unsupported_syntax_errors. iter ( ) . map ( |error| {
246
252
let start_location = source_code. source_location ( error. range . start ( ) ) ;
247
253
let end_location = source_code. source_location ( error. range . end ( ) ) ;
248
254
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ fn syntax_error() {
65
65
fn unsupported_syntax_error ( ) {
66
66
check ! (
67
67
"match 2:\n case 1: ..." ,
68
- r#"{}"# ,
68
+ r#"{"preview": true }"# ,
69
69
[ ExpandedMessage {
70
70
code: None ,
71
71
message: "SyntaxError: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)" . to_string( ) ,
You can’t perform that action at this time.
0 commit comments