title: Return None from Enum
body: <p>I have simple enum:</p>
  
  <pre><code>from enum import Enum
  
  
  class ColorEnum(Enum):
      RED = 1
      GREEN = 2
      BLUE = 3
  
      @classmethod
      def _missing_(cls, value):
          if value is None:
              return None
          super()._missing_(value)
  </code></pre>
  
  <p>As you can see if None is passed to ColorEnum init it will return None. This works for Python 3.6. But does not work for Python 3.7 when it fails with ValueError:</p>
  
  <blockquote>
    <p>ValueError: None is not a valid ColorEnum</p>
  </blockquote>
  
  <p>For Python 3.6 method <code>__new__</code> looks like this:</p>
  
  <pre><code>class Enum(metaclass=EnumMeta):
      """Generic enumeration.
  
      Derive from this class to define new enumerations.
  
      """
      def __new__(cls, value):
          # all enum instances are actually created during class construction
          # without calling this method; this method is called by the metaclass'
          # __call__ (i.e. Color(3) ), and by pickle
          if type(value) is cls:
              # For lookups like Color(Color.RED)
              return value
          # by-value search for a matching enum member
          # see if it's in the reverse mapping (for hashable values)
          try:
              if value in cls._value2member_map_:
                  return cls._value2member_map_[value]
          except TypeError:
              # not there, now do long search -- O(n) behavior
              for member in cls._member_map_.values():
                  if member._value_ == value:
                      return member
          # still not found -- try _missing_ hook
          return cls._missing_(value)
  </code></pre>
  
  <p>For Python 3.7:</p>
  
  <pre><code>class Enum(metaclass=EnumMeta):
      """Generic enumeration.
  
      Derive from this class to define new enumerations.
  
      """
      def __new__(cls, value):
          # all enum instances are actually created during class construction
          # without calling this method; this method is called by the metaclass'
          # __call__ (i.e. Color(3) ), and by pickle
          if type(value) is cls:
              # For lookups like Color(Color.RED)
              return value
          # by-value search for a matching enum member
          # see if it's in the reverse mapping (for hashable values)
          try:
              return cls._value2member_map_[value]
          except KeyError:
              # Not found, no need to do long O(n) search
              pass
          except TypeError:
              # not there, now do long search -- O(n) behavior
              for member in cls._member_map_.values():
                  if member._value_ == value:
                      return member
          # still not found -- try _missing_ hook
          try:
              exc = None
              result = cls._missing_(value)
          except Exception as e:
              exc = e
              result = None
          if isinstance(result, cls):
              return result
          else:
              ve_exc = ValueError("%r is not a valid %s" % (value, cls.__name__))
              if result is None and exc is None:
                  raise ve_exc
              elif exc is None:
                  exc = TypeError(
                          'error in %s._missing_: returned %r instead of None or a valid member'
                          % (cls.__name__, result)
                          )
              exc.__context__ = ve_exc
              raise exc
  </code></pre>
  
  <p>So I would like to get None if None is passed to init. How can I archive that?</p>