This is what I want to do:
class Base:
_type = None
name: str = _type.name
class a(Base):
_type = UnityType
a_instance = a()
a_instance.name # Expecting UnityType.name to be some string.
While trying this, I get 'NoneType' object has no attribute 'name'. The reason is clear and understandable. But how can I pass the responsibility of implementing a variable class to a subclass?
_typeis astrin the first place if you want it to be something that has anameattribute...__init__()and put the name on the instance when the instance is initialized? Although it's not clear what should happen when someone createsBase().a._type.nameto work ,onlya_instance._type.name, initialize the attributes ina's__init__method. If you need it to work onaitself, put it in the metaclass.