File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -2653,7 +2653,7 @@ match 2:
26532653 "
26542654 ) ;
26552655
2656- // syntax error on 3.9
2656+ // ok on 3.9 without preview
26572657 assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
26582658 . args( STDIN_BASE_OPTIONS )
26592659 . args( [ "--stdin-filename" , "test.py" ] )
@@ -2664,6 +2664,30 @@ match 2:
26642664match 2:
26652665 case 1:
26662666 print("it's one")
2667+ "#
2668+ ) ,
2669+ @r"
2670+ success: true
2671+ exit_code: 0
2672+ ----- stdout -----
2673+ All checks passed!
2674+
2675+ ----- stderr -----
2676+ "
2677+ ) ;
2678+
2679+ // syntax error on 3.9 with preview
2680+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
2681+ . args( STDIN_BASE_OPTIONS )
2682+ . args( [ "--stdin-filename" , "test.py" ] )
2683+ . arg( "--target-version=py39" )
2684+ . arg( "--preview" )
2685+ . arg( "-" )
2686+ . pass_stdin(
2687+ r#"
2688+ match 2:
2689+ case 1:
2690+ print("it's one")
26672691"#
26682692 ) ,
26692693 @r"
Original file line number Diff line number Diff line change @@ -429,11 +429,17 @@ pub fn lint_only(
429429 & parsed,
430430 ) ;
431431
432+ let syntax_errors = if settings. preview . is_enabled ( ) {
433+ parsed. syntax_errors ( )
434+ } else {
435+ & [ ]
436+ } ;
437+
432438 LinterResult {
433439 messages : diagnostics_to_messages (
434440 diagnostics,
435441 parsed. errors ( ) ,
436- parsed . syntax_errors ( ) ,
442+ syntax_errors,
437443 path,
438444 & locator,
439445 & directives,
@@ -582,12 +588,18 @@ pub fn lint_fix<'a>(
582588 report_failed_to_converge_error ( path, transformed. source_code ( ) , & diagnostics) ;
583589 }
584590
591+ let syntax_errors = if settings. preview . is_enabled ( ) {
592+ parsed. syntax_errors ( )
593+ } else {
594+ & [ ]
595+ } ;
596+
585597 return Ok ( FixerResult {
586598 result : LinterResult {
587599 messages : diagnostics_to_messages (
588600 diagnostics,
589601 parsed. errors ( ) ,
590- parsed . syntax_errors ( ) ,
602+ syntax_errors,
591603 path,
592604 & locator,
593605 & directives,
You can’t perform that action at this time.
0 commit comments