Type safety and Jupyter Kernel messages


Maybe this doesn’t matter much, but it’s something that could help reduce bugs that compilers could catch.

Specific use-case is that we ingest kernel messages to construct the activity record in Gigantum, trigger git commits, etc. As it stands, it’s too much of a pain to strictly type the messages, so they get typed as Dict[str, Any] in mypy. Folks that use languages with rich type systems like Elm or Haskell, or Clojure spec will see an opportunity to get the compiler to help you more there…

The messages are returned by get_iopub_msg() in the client code.

Has anyone bumped into typing and Jupyter messages and come up with a better solution than Dict[str, Any]?

I know @ivanov was leading an effort to work with Elm on the front-end, so this could be vaguely related to that effort - generating a well-typed interface between the kernels and a front end.


We extensively type Kernel messages in JupyterLab using TypeScript, and nteract also has its own TypeScript typings for kernel messages.


Thank you @jasongrout! I had a quick look around the main jupyterlab repo, and there are many packages referenced there.

So, I’ll get back to this at some point, but if anyone can quickly point me to where jupyterlab processes kernel messages in typescript, I’d be much obliged!


Relevant links: