# Python type hints for ROOT/RooFit

**URL:** <https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143>\
**Category:** ROOT\
**Tags:** python\
**Created:** [March 24, 2021, 12:11pm UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143 "2021-03-24T12:11:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyW](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f05b48/32.png) [@AndyW](https://root-forum.cern.ch/u/AndyW)\
**Post date:** [March 24, 2021, 12:11pm UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/1 "2021-03-24T12:11:54Z")

</div>

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…

Thanks,  
Andy.

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [March 25, 2021, 8:26am UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/2 "2021-03-25T08:26:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AndyW](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f05b48/32.png) [@AndyW](https://root-forum.cern.ch/u/AndyW)\
**Post date:** [March 25, 2021, 10:01am UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/3 "2021-03-25T10:01:24Z")

</div>

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

Andy.

---

<div class="post-metadata">

**Author:** ![AndyW](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f05b48/32.png) [@AndyW](https://root-forum.cern.ch/u/AndyW)\
**Post date:** [April 6, 2021, 1:59pm UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/4 "2021-04-06T13:59:26Z")

</div>

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

Andy.

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [April 14, 2021, 9:33am UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/5 "2021-04-14T09:33:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 28, 2021, 9:34am UTC](https://root-forum.cern.ch/t/python-type-hints-for-root-roofit/44143/6 "2021-04-28T09:34:02Z")

</div>

Closed on April 28, 2021, 9:34am UTC

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