I have an enum with a set as value for the items. In a property method I would like to return an intersection of the previous chained enum. But the result type of the property should be the same enum class.
Given this abstract example
from enum import Enum
class Letters(Enum):
abc = {'a', 'b', 'c'}
@property
def a(self):
""" Returns a subset of a Letters Enum """
letter = {'a'}
return letter.intersection(self.value)
The type of an Item is an enum of Letters, which is correct
print(type(Letters.abc))
# prints <enum 'Letters'>
But when I call the property of the resulting enum, it is of type set
print(type(Letters.abc.a))
# prints <class 'set'>
# I want this to be <enum 'Letters'> instead
How can I change the code so that the property returns a value of type enum?