Instagram / LibCST

A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
https://libcst.readthedocs.io/
Other
1.57k stars 192 forks source link

Fix parsing list matchers without explicit brackets #1097

Closed zsol closed 10 months ago

zsol commented 10 months ago

Fix parsing list matchers without explicit brackets

match a:
  case 1, 2: pass

This is parsed correctly by the grammar, but the default values of MatchList.lbracket and MatchList.rbracket are inconsistent between Python and Rust, causing the above snippet to round-trip (from Python) to:

match a:
  case [1, 2]: pass

Fixes #1096.


Stack created with Sapling. Best reviewed with ReviewStack.

codecov-commenter commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (a2a60c1) 91.09% compared to head (ee806cd) 91.09%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1097 +/- ## ======================================= Coverage 91.09% 91.09% ======================================= Files 255 255 Lines 26561 26561 ======================================= Hits 24195 24195 Misses 2366 2366 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.