Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 30, 2021

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