title: overwrite __contains__ in metaclass for defining own Enums
body: <p>I have a type derived from Enum and a metaclass derived from EnumMeta. I have overridden the magic method __contains__ in the metaclass (I use python-3.6):</p>
  <pre><code>from enum import Enum, EnumMeta
  
  class MyMeta(EnumMeta):
      def __contains__(clsmeta, item):
          try:
              clsmeta(item)
          except ValueError:
              return False
          return True
  
  class MyEnum(Enum, metaclass=MyMeta):
      Enum1 = 1
      Enum2 = 2
      Enum3 = 3
  
  print(3 in MyEnum)
  </code></pre>
  <p>The result is <strong>True</strong>, as expected.</p>
  <p>If I remove the definition of the __contains__ method from the metaclass and modify the attrs dictionary, the __contains__ method defined in enum.py is called and returns <strong>False</strong> or throws an exception in Python 3.8.</p>
  <pre><code>from enum import Enum, EnumMeta
  
  def enum_contains(clsmeta, item):
      try:
          clsmeta(item)
      except ValueError:
          return False
      return True
  
  class MyMeta(EnumMeta):
      def __new__(clsmeta, name, bases, attrs):
          attrs['__contains__'] = classmethod(enum_contains)
          return super().__new__(clsmeta, name, bases, attrs)
  
  class MyEnum(Enum, metaclass=MyMeta):
      Enum1 = 1
      Enum2 = 2
      Enum3 = 3
  
  print(3 in MyEnum)
  </code></pre>
  <p>But if I change the print line and call the magic method __contains__ directly on the class it works like expected:</p>
  <pre><code>print(MyEnum.__contains__(3))
  </code></pre>
  <p>returns <strong>True</strong>.</p>
  <p>My question is: why I have to call __contains__ explicitly when I want to apply it on a class (even when I use classmethod)?</p>