使用FunctionalAPI,我想输入我的枚举,这样它就会有一个默认的已知值。
示例:
class MyBaseClass:
...
class DerivedA(MyBaseClass):
...
class DerivedB(MyBaseClass):
...
DerivedChoice = enum.Enum('DerivedChoice', {cls.__name__: cls for cls in (DerivedA, DerivedB)})
foo: DerivedChoice = DerivedChoice.DerivedB
foo.value # <- this should be `MyBaseClass`
1条答案
按热度按时间s3fp2yjn1#
这里有一个不错的解决方案
用法:
这一个似乎在VSCode上工作