File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -172,6 +172,12 @@ pub(crate) fn check(
172172 )
173173 } ) ;
174174
175+ let unsupported_syntax_errors = if settings. linter . preview . is_enabled ( ) {
176+ parsed. unsupported_syntax_errors ( )
177+ } else {
178+ & [ ]
179+ } ;
180+
175181 let lsp_diagnostics = lsp_diagnostics. chain (
176182 show_syntax_errors
177183 . then ( || {
@@ -186,7 +192,7 @@ pub(crate) fn check(
186192 encoding,
187193 )
188194 } )
189- . chain ( parsed . unsupported_syntax_errors ( ) . iter ( ) . map ( |error| {
195+ . chain ( unsupported_syntax_errors. iter ( ) . map ( |error| {
190196 unsupported_syntax_error_to_lsp_diagnostic (
191197 error,
192198 & source_kind,
Original file line number Diff line number Diff line change @@ -205,6 +205,12 @@ impl Workspace {
205205
206206 let source_code = locator. to_source_code ( ) ;
207207
208+ let unsupported_syntax_errors = if self . settings . linter . preview . is_enabled ( ) {
209+ parsed. unsupported_syntax_errors ( )
210+ } else {
211+ & [ ]
212+ } ;
213+
208214 let messages: Vec < ExpandedMessage > = diagnostics
209215 . into_iter ( )
210216 . map ( |diagnostic| {
@@ -242,7 +248,7 @@ impl Workspace {
242248 fix : None ,
243249 }
244250 } ) )
245- . chain ( parsed . unsupported_syntax_errors ( ) . iter ( ) . map ( |error| {
251+ . chain ( unsupported_syntax_errors. iter ( ) . map ( |error| {
246252 let start_location = source_code. source_location ( error. range . start ( ) ) ;
247253 let end_location = source_code. source_location ( error. range . end ( ) ) ;
248254
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ fn syntax_error() {
6565fn unsupported_syntax_error ( ) {
6666 check ! (
6767 "match 2:\n case 1: ..." ,
68- r#"{}"# ,
68+ r#"{"preview": true }"# ,
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( ) ,
You can’t perform that action at this time.
0 commit comments