I have an enumeration ResourceType that inherits from both namedtuple and Enum, and I don't override __str__ or __repr__ anywhere. When I format an instance of that enum I unexpectedly get just the undecorated value, as opposed to either the repr() or the str(). How is this possible? What is being called?
Enum details (simplified):
from enum import Enum, auto
from collections import namedtuple
class ResourceType(namedtuple('ResourceType', 'value ext required'), Enum):
RGB = auto(), '.png', True
Output:
>>> repr(ResourceType.RGB)
"<ResourceType.RGB: ResourceType(value=<enum.auto object at 0x7f44b7d48d30>, ext='.png', required=True)>"
>>> str(ResourceType.RGB)
'ResourceType.RGB'
>>> f"{ResourceType.RGB}"
"ResourceType(value=<enum.auto object at 0x7f44b7d48d30>, ext='.png', required=True)"
The last value is neither the repr() nor the str(), so even if namedtuple is providing that string, why does it not also provide the str/repr?