You cannot get a reference to the class, because the class has yet to be created. Your parent frame points a temporary function, whose locals()
when it completes will be used as the class body.
As such, all you need to do is add your variables to the parent frame locals, and these will be added to the class when class construction is finished.
Short demo:
>>> def foo():
... import sys
... flocals = sys._getframe(1).f_locals
... flocals['ham'] = 'eggs'
...
>>> class Bar:
... foo()
...
>>> dir(Bar)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__locals__', '__lt__', '__module__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'ham']
>>> Bar.ham
'eggs'