-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add match
and case
syntax Python 3.10
#237
Conversation
match
and case
syntaxmatch
and case
syntax Python 3.10
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? |
Hi, whats the current status of this pull request? I'd love to have |
I am waiting for this pull request too. |
Any updates? |
I too would like this |
Nice feature! |
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. |
This isn't true that built-in python highlighter of VS Code supports match/case. 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
match
andcase
keywords.This PR adds a regular expression to recognize them as
keyword.control.flow.python
if present in amatch
statement. Since they are onlysoft
keywords 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