title: How can I construct an enum.Enum from a dictionary of values?
body: <p>I'd like to generate some types at runtime from a config file. For simplity, let's assume I already have the data loaded as a python dictionary:</p>
  
  <pre><code>color_values = dict(RED = 1, YELLOW = 2, GREEN = 3)
  </code></pre>
  
  <p>How can I transform this into the type (using <a href="https://docs.python.org/3/library/enum.html" rel="noreferrer"><code>enum</code></a>)</p>
  
  <pre><code>class Color(enum.Enum):
      RED = 1
      YELLOW = 2
      GREEN = 3
  </code></pre>
  
  <p>The following doesn't work</p>
  
  <pre><code>def make_enum(name, values):
      return type(name, (enum.Enum,), values)
  </code></pre>
  
  
  
  <pre><code>&gt;&gt;&gt; Color = make_enum('Color', color_values)
  AttributeError: 'dict' object has no attribute '_member_names'
  </code></pre>