File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -2669,6 +2669,62 @@ fn walrus_before_py38() {
26692669 ) ;
26702670}
26712671
2672+ #[ test]
2673+ fn relaxed_decorator_before_py39 ( ) {
2674+ // adapted from [PEP 614](https://peps.python.org/pep-0614/)
2675+ let stdin = r#"
2676+ buttons = []
2677+
2678+ @buttons[0].clicked.connect # error
2679+ def spam1(): ...
2680+
2681+ @eval("buttons[0].clicked.connect") # ok
2682+ def spam2(): ...
2683+
2684+ def _(x): return x
2685+ @_(buttons[0].clicked.connect) # ok
2686+ def spam3(): ...
2687+ "# ;
2688+
2689+ // ok
2690+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
2691+ . args( STDIN_BASE_OPTIONS )
2692+ . args( [ "--stdin-filename" , "test.py" ] )
2693+ . arg( "--target-version=py39" )
2694+ . arg( "--ignore=E701" )
2695+ . arg( "-" )
2696+ . pass_stdin( stdin) ,
2697+ @r"
2698+ success: true
2699+ exit_code: 0
2700+ ----- stdout -----
2701+ All checks passed!
2702+
2703+ ----- stderr -----
2704+ "
2705+ ) ;
2706+
2707+ // not ok on 3.8 with preview
2708+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
2709+ . args( STDIN_BASE_OPTIONS )
2710+ . args( [ "--stdin-filename" , "test.py" ] )
2711+ . arg( "--target-version=py38" )
2712+ . arg( "--ignore=E701" )
2713+ . arg( "--preview" )
2714+ . arg( "-" )
2715+ . pass_stdin( stdin) ,
2716+ @r"
2717+ success: false
2718+ exit_code: 1
2719+ ----- stdout -----
2720+ test.py:4:1: SyntaxError: Cannot use named expression in decorator on Python 3.8 (syntax was added in Python 3.9)
2721+ Found 1 error.
2722+
2723+ ----- stderr -----
2724+ "
2725+ ) ;
2726+ }
2727+
26722728#[ test]
26732729fn match_before_py310 ( ) {
26742730 // ok on 3.10
You can’t perform that action at this time.
0 commit comments