Using this snippet:
import sys
import yaml
try:
from enum import ReprEnum
except ImportError:
from enum import Enum as ReprEnum
class MyEnum(int, ReprEnum):
foo = 123
print('Python version:', ''.join(map(str, sys.version_info[:3])))
print(yaml.dump({'test': MyEnum.foo}))
I get very different output on Python 3.10 and 3.11:
3.10 output:
Python version: 3.10.12
test: !!python/object/apply:__main__.MyEnum
- 123
3.11 output:
Python version: 3.11.4
test: !!python/object/apply:builtins.getattr
- !!python/name:__main__.MyEnum ''
- foo
My guess would be that it's related to the many changes in Python 3.11's enum module, but I'd like to understand why this changed...