-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPStatus has incomplete dir() listing #84265
Comments
The dir() listing omits the attributes "description" and "phrase": >>> import http
>>> from pprint import pp
>>> r = http.HTTPStatus(404)
>>> pp(vars(r))
{'_value_': 404,
'phrase': 'Not Found',
'description': 'Nothing matches the given URI',
'_name_': 'NOT_FOUND',
'__objclass__': <enum 'HTTPStatus'>}
>>> r.value
404
>>> r.name
'NOT_FOUND'
>>> r.description
'Nothing matches the given URI'
>>> r.phrase
'Not Found'
>>> dir(r)
['__class__', '__doc__', '__module__', 'as_integer_ratio', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'name', 'numerator', 'real', 'to_bytes', 'value'] One fix would be to teach IntEnum.__dir__() to include entries in the instance dict. Another fix would be to provide a way for a IntEnum subclass to add to the known members list. |
Adding to the existing dir() is as easy as writing one's own __dir__. I think using the instance dict and omitting any keys with a leading underscore will do the right thing most of the time. The fix should into |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: