I have the following working in python 3.8.1
@unique
class Encoder(IntFlag):
# H1 sensor signal
H1 = 0x00
# H2 sensor signal
H2 = 0x01
# H3 sensor signal
H3 = 0x02
Then I am trying to catch with an assert if the value is not within the enum, i.e.
from enum import unique, IntFlag
signal = Encoder.H1
assert signal in iter(Encoder), f"Valid Encoder line is integer 0 to 2 inclusive."
I noticed on python 3.8, the signal in iter(Encoder) returns True but False in python 3.12.4
It might be a hange in some version from 3.8.1 to 3.12.4 but I am not sure where to star looking for getting this working in both.