title: How to add custom codes to HTTPStatus in Python 3.5?
body: <p>My HTTP client uses the Python <em>requests</em> library to access an API proxied by CloudFlare. The client converts the numerical response status code to an <code>HTTPStatus</code> enum instance. Simplified ...</p>
  
  <pre><code>import requests
  from http import HTTPStatus
  
  url = ...
  response = requests.get(url)
  status = HTTPStatus(response.status_code)
  </code></pre>
  
  <p>The CloudFlare proxy service can return some unofficial 5xx HTTP status codes: <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#CloudFlare" rel="nofollow">https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#CloudFlare</a>. These cause <code>HTTPStatus</code> to raise a <code>ValueError</code> because codes such as 522 (Connection Timed Out) are not members of the <code>HTTPStatus</code> enum defined in Python's <code>lib/http/__init__.py</code>.</p>
  
  <p>How can I add the unoffical CloudFlare status codes to the <code>HTTPStatus</code> enum? Or, how can I load the <code>HTTPStatus</code> enum members into some other enum along with the unoffical CloudFlare status codes?</p>
  
  <p>The Python 3.5 <code>Enum</code> documentation, <a href="https://docs.python.org/3/library/enum.html" rel="nofollow">https://docs.python.org/3/library/enum.html</a>, describes restrictions that have thwarted me thus far.</p>
  
  <blockquote>
    <p>Section 8.13.9: Subclassing an enumeration is allowed only if the
    enumeration does not define any members.</p>
    
    <p>Section 8.13.14.2: The most interesting thing about <code>Enum</code> members is
    that they are singletons. <code>EnumMeta</code> creates them all while it is
    creating the <code>Enum</code> class itself, and then puts a custom <code>__new__()</code>
    in place to ensure that no new ones are ever instantiated by returning
    only the existing member instances.</p>
  </blockquote>