I've created the following class and instance:
class _Colors:
def __init__(self):
[self.__setattr__(shade.capitalize() + color.capitalize(), shade + "-" + color) for shade in ['dark', 'light']
for color in ['pink', 'green', 'blue', 'red', 'teal', 'brown', 'orange', 'purple', 'warm-grey']]
self.__setattr__('None', 'none')
self.__setattr__('Null', 'null')
colors = _Colors()
Because the attributes are added at runtime they don't appear as completion hints when typing in my IDE, which in this case is PyCharm
Example: IDE completion hint example
I've seen other Python modules create attributes and methods at runtime that do show up as completion hints but I've never been able to figure out how they do it.
How can I tell an IDE about class attributes that are created at runtime before runtime?
So far, I've tried creating the color object as an array, as a dictionary and as a class, and none of them will provide completion hints as-writte when they are created dynamically at runtime.
I would like to begin typing the class instance name with a dot i.e.: colors. then have all the colors that are crated at runtime to be available as hints, such as colors.DarkRed