Python type hints for ROOT/RooFit

Hi all,

I would like to try and include type hinting in my python code (so I can run mypy over my packages), but I’m struggling to get anything working whenever I pull in anything from import ROOT.

So I have a couple of questions about PyROOT/hinting, if anyone else has looked at this before…

  • Is there any plan for PyROOT to support type hinting for the built-in types?

  • Has anyone managed to get stubgen to generate a useful stub for the ROOT/RooFit types? I tried this morning but my python’s not good enough to be able to get anything useful out of it!

  • Has anyone managed to generate a stub file by hand? I’m only interested in a handful of RooFit classes, so I’d be happy to do them by hand, just so I can run the static analysis tools. Has anyone got an example I could use as a primer…


Hi Andy,
We’ll likely need @etejedor to reply here - he will be back in about one week. Please ping him should you not have a response within 10 days or so!
Cheers, Axel.

Cheers @Axel, I will follow up with him when he’s back!


Hi @etejedor, Do you have any views on this?


Hi @AndyW ,

How would you apply type hinting with PyROOT? There are actually no ROOT Python classes, PyROOT generates Python proxies for your C++ objects/classes dynamically by interrogating the C++ interpreter. This also means that there are no actual Python ROOT classes to which you can apply stubgen and get your classes annotated.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.