Search code examples
jupyter-notebookjupytersyntax-highlightingjupyter-labpython-3.10

Jupyter not syntax highlighting match case


I am using a fresh installation from conda, python 3.10.4, no extensions installed.

What's extra weird is that in the traceback it is highlighted correctly.

I already tried deleting ~/.jupyter to reset possible configurations.

enter image description here


Solution

  • Match-case is a recent addition to Python; it seems that CodeMirror, the editor which is used by Jupyter has not added match and case to the list of keywords. It might not be as trivial as it seems, because those are not hard keywords (as raise) but instead soft keywords. The traceback is highlighted using a different library which added support for match and case.

    Update: the match/case support was added in CodeMirror via https://github.com/codemirror/dev/issues/984 and https://github.com/lezer-parser/python/pull/11 which is now working in JupyterLab 4.0 (https://github.com/jupyterlab/jupyterlab/issues/13379).