black/tests/data/cases/pattern_matching_with_if_stmt.py
rdrll f78b15712a
Fix formatting for if clauses in match-case blocks (#4269)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-03-16 07:38:07 -07:00

73 lines
2.1 KiB
Python

# flags: --preview --minimum-version=3.10
match match:
case "test" if case != "not very loooooooooooooog condition": # comment
pass
match smth:
case "test" if "any long condition" != "another long condition" and "this is a long condition":
pass
case test if "any long condition" != "another long condition" and "this is a looooong condition":
pass
case test if "any long condition" != "another long condition" and "this is a looooong condition": # some additional comments
pass
case test if (True): # some comment
pass
case test if (False
): # some comment
pass
case test if (True # some comment
):
pass # some comment
case cases if (True # some comment
): # some other comment
pass # some comment
case match if (True # some comment
):
pass # some comment
# case black_test_patma_052 (originally in the pattern_matching_complex test case)
match x:
case [1, 0] if x := x[:0]:
y = 1
case [1, 0] if (x := x[:0]):
y = 1
# output
match match:
case "test" if case != "not very loooooooooooooog condition": # comment
pass
match smth:
case "test" if (
"any long condition" != "another long condition" and "this is a long condition"
):
pass
case test if (
"any long condition" != "another long condition"
and "this is a looooong condition"
):
pass
case test if (
"any long condition" != "another long condition"
and "this is a looooong condition"
): # some additional comments
pass
case test if True: # some comment
pass
case test if False: # some comment
pass
case test if True: # some comment
pass # some comment
case cases if True: # some comment # some other comment
pass # some comment
case match if True: # some comment
pass # some comment
# case black_test_patma_052 (originally in the pattern_matching_complex test case)
match x:
case [1, 0] if x := x[:0]:
y = 1
case [1, 0] if x := x[:0]:
y = 1