我无法解释为什么动态创建枚举条目时会收到pylint "<class 'AttributeError'>: 'For' object has no attribute 'targets'"
警告。
我在代码中看不到警告的任何原因。
from aenum import IntEnum
class Commands(IntEnum):
_ignore_ = 'Commands index'
_init_ = 'value string'
BEL = 0x07, 'Bell'
Commands = vars()
for index in range(4):
Commands[f'DC{index + 1}'] = 0x11 + index, f'Device Control {index + 1}'
for command in Commands:
print(f"0x{command.value:02X} is {command.string}")
代码工作正常,但我不希望收到警告!