tests/data/line_ranges_formatted/pattern_matching.py
raw| 1 | # flags: --minimum-version=3.10 |
| 2 | |
| 3 | |
| 4 | def pattern_matching(): |
| 5 | match status: |
| 6 | case 1: |
| 7 | return "1" |
| 8 | case [single]: |
| 9 | return "single" |
| 10 | case [ |
| 11 | action, |
| 12 | obj, |
| 13 | ]: |
| 14 | return "act on obj" |
| 15 | case Point(x=0): |
| 16 | return "class pattern" |
| 17 | case {"text": message}: |
| 18 | return "mapping" |
| 19 | case { |
| 20 | "text": message, |
| 21 | "format": _, |
| 22 | }: |
| 23 | return "mapping" |
| 24 | case _: |
| 25 | return "fallback" |