-
Notifications
You must be signed in to change notification settings - Fork 97
Add match and case syntax Python 3.10
#237
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
Conversation
match and case syntax (削除ここまで)match and case syntax Python 3.10 (追記ここまで)
norabelrose
commented
Jan 29, 2022
It's no super clear to me why this PR is "failing" the CI tests. When I look at the logs it looks like none of the actual MagicPython tests fail, but later some bizarre error is thrown from inside Atom. When I clone this branch and run the tests myself, they all pass.
Can we try to get this merged soon? Does something need to be fixed with the CI?
cgahr
commented
Mar 17, 2022
Hi, whats the current status of this pull request? I'd love to have match case statements.
tiararosebiezetta
commented
Mar 25, 2022
I am waiting for this pull request too.
ruthus18
commented
Apr 15, 2022
Any updates?
spagh-eddie
commented
Apr 25, 2022
I too would like this
wszqkzqk
commented
May 31, 2022
Nice feature!
cdce8p
commented
May 31, 2022
I no longer need this myself. VS Code and Pylance in particular have added syntax highlighting for match / case a while ago. If someone else would like to continue with the PR, feel free to reuse it.
Just to note, although I believe the regex is quite good already. There might still be some edge cases left which aren't covered. I just haven't used it in a long time.
neumond
commented
Sep 12, 2022
This isn't true that built-in python highlighter of VS Code supports match/case.
I've built this pull request and it works for me. Haven't tested it thoroughly though.
For Ubuntu 22.04 and snap distribution of Codium:
sudo apt install nodejs npm git clone 'https://github.com/MagicStack/MagicPython' cd MagicPython/ git fetch origin pull/237/head git checkout FETCH_HEAD make make release npm install --dev cson ./node_modules/.bin/cson2json grammars/MagicPython.cson > grammars/MagicPython.tmLanguage.json sudo mount --bind grammars/MagicPython.tmLanguage.json /snap/codium/current/usr/share/codium/resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json
This isn't permanent fix, it requires mounting patched json after each reboot. Json itself could be made more compact, as the one shipped with codium.
Python 3.10 will add pattern matching with the
matchandcasekeywords.This PR adds a regular expression to recognize them as
keyword.control.flow.pythonif present in amatchstatement. Since they are onlysoftkeywords and still allowed as normal variable names, it's not possible to simply add them to the list of the other keywords.Closes: #235
Example
Screen Shot 2021年05月01日 at 15 21 44