This is an oddity which results in data not roundtripping through libcst accurately. It also makes it impossible to know what the original file contents were.
If a match-case is used and the case is an unparenthesized, unbracketed expression, libcst parses this to have lbracket and rbracket incorrectly populated.
Here's a reproducer:
x = (1, 2)
match x:
case 1, 2:
print("x matches (1, 2)")
case _:
print("x does not match (1, 2)")
Attempting to simply load and dump this module produces case [1, 2]:.
Inspecting the results of parse_module, I find a parse shaped like...
This is an oddity which results in data not roundtripping through libcst accurately. It also makes it impossible to know what the original file contents were.
If a match-case is used and the case is an unparenthesized, unbracketed expression, libcst parses this to have
lbracket
andrbracket
incorrectly populated.Here's a reproducer:
Attempting to simply load and dump this module produces
case [1, 2]:
.Inspecting the results of
parse_module
, I find a parse shaped like...