简体   繁体   English

Python 3枚举列表值不支持成员资格测试

[英]Python 3 Enumeration List Value doesn't support membership test

from enum import IntEnum
from typing import List
class EnumClass(IntEnum):
   A = 1
   B = 2

   @staticmethod
   def listofconditions() -> 'List[EnumClass]':
      return [EnumClass.A.numerator, \
              EnumClass.B.numerator]


if 1 in EnumClass.listofconditions:
    pass

yields: 产量:

[pylint]:E1135 Value 'EnumClass.listofconditions' doesn't support membership test

(I posted this for others Googling a solution to this cryptic message in order to makes sense of it. Solution to follow) (我为其他人发布了此信息,以使其理解此隐秘消息的解决方案。后续解决方案)

将代码更改为:

if 1 in EnumClass.listofconditions():

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM