Skip to content

Comments

Fix line generation for match match: / case case:#2661

Merged
ichard26 merged 1 commit intopsf:mainfrom
isidentical:handle-softkws-better
Nov 30, 2021
Merged

Fix line generation for match match: / case case:#2661
ichard26 merged 1 commit intopsf:mainfrom
isidentical:handle-softkws-better

Conversation

@isidentical
Copy link
Collaborator

Fixes #2660

"""Visit either a match or case statement."""
normalize_invisible_parens(node, parens_after=set())

yield from self.line()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the correct solution; it originates from the assumptions that for each match_statement/case_statement node, there will be only one valid match/case keyword for the context. So we simply yield a line; and for all following encounters of child nodes, we process them as usual.

...
case func(match, case):
...
case another:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed some syntax errors in this file (e.g a name pattern can't be followed by anything else) to ensure everything is also parsable by the python parser.

@isidentical
Copy link
Collaborator Author

@JelleZijlstra that was fast 🚀

@ichard26 ichard26 merged commit b336b39 into psf:main Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

match/case statements containing those soft-keywords gets wrongly separated

3 participants