Title: `enum.Enum.__dir__` docs do not mention enum members in return value · Issue #104235 · python/cpython · GitHub
Open Graph Title: `enum.Enum.__dir__` docs do not mention enum members in return value · Issue #104235 · python/cpython
X Title: `enum.Enum.__dir__` docs do not mention enum members in return value · Issue #104235 · python/cpython
Description: 3.12 documentation for enum.Enum.__dir__ says that this method returns "['__class__', '__doc__', '__module__', 'name', 'value'] and any public methods defined on self.__class__", but this is not true, e.g. when using the code provided: >...
Open Graph Description: 3.12 documentation for enum.Enum.__dir__ says that this method returns "['__class__', '__doc__', '__module__', 'name', 'value'] and any public methods defined on self.__class__", but this is not tr...
X Description: 3.12 documentation for enum.Enum.__dir__ says that this method returns "['__class__', '__doc__', '__module__', 'name', 'value'] and any public methods d...
Opengraph URL: https://github.com/python/cpython/issues/104235
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`enum.Enum.__dir__` docs do not mention enum members in return value","articleBody":"3.12 [documentation](https://docs.python.org/3.12/library/enum.html#enum.Enum.__dir__) for `enum.Enum.__dir__` says that this method returns \"`['__class__', '__doc__', '__module__', 'name', 'value']` and any public methods defined on `self.__class__`\", but this is not true, e.g. when using the code provided:\r\n```python\r\n\u003e\u003e\u003e from enum import Enum\r\n\u003e\u003e\u003e from datetime import date\r\n\u003e\u003e\u003e class Weekday(Enum):\r\n... MONDAY = 1\r\n... TUESDAY = 2\r\n... WEDNESDAY = 3\r\n... THURSDAY = 4\r\n... FRIDAY = 5\r\n... SATURDAY = 6\r\n... SUNDAY = 7\r\n... @classmethod\r\n... def today(cls):\r\n... print('today is %s' % cls(date.today().isoweekday()).name)\r\n... \r\n\u003e\u003e\u003e dir(Weekday.SATURDAY)\r\n['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']\r\n```\r\n\r\n\r\nAlso it seems that `test_enum` has bug in it, because it doesn't detect the error above if invoked through `libregrtest` (as `./python -m test test_enum`), but direct run of `test_enum` or `doctest` on `enum` documentation fails:\r\n```\r\n$ ./python -m test.test_enum\r\n...........................................................................................................................................s.s......s........................................................................................................................................................................................................................................................................................................................s...........................................s...............................................................................................F\r\n======================================================================\r\nFAIL: /home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst\r\nDoctest: enum.rst\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n File \"/home/chgnrdv/cpython/Lib/doctest.py\", line 2228, in runTest\r\n raise self.failureException(self.format_failure(new.getvalue()))\r\nAssertionError: Failed doctest test for enum.rst\r\n File \"/home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst\", line 0\r\n\r\n----------------------------------------------------------------------\r\nFile \"/home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst\", line 297, in enum.rst\r\nFailed example:\r\n dir(Weekday.SATURDAY)\r\nExpected:\r\n ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']\r\nGot:\r\n ['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']\r\n\r\n\r\n----------------------------------------------------------------------\r\nRan 602 tests in 5.113s\r\n\r\nFAILED (failures=1, skipped=5)\r\n```\r\n```\r\n./python -m doctest Doc/library/enum.rst \r\n**********************************************************************\r\nFile \"Doc/library/enum.rst\", line 297, in enum.rst\r\nFailed example:\r\n dir(Weekday.SATURDAY)\r\nExpected:\r\n ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']\r\nGot:\r\n ['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']\r\n**********************************************************************\r\n1 items had failures:\r\n 1 of 88 in enum.rst\r\n***Test Failed*** 1 failures.\r\n```\r\n\r\nI'm working on fixes for both errors.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104236\n* gh-104237\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/chgnrdv","@type":"Person","name":"chgnrdv"},"datePublished":"2023-05-06T13:13:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/104235/cpython/issues/104235"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ed32bd31-d7bd-0fe1-0d94-682a12443545 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DC02:1A8429:CABFFB:10E4E27:696B88C8 |
| html-safe-nonce | 8d9041cc6f8962e119f527854d6104118b90ab3245fa7a6d56ca07204b1ccf5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQzAyOjFBODQyOTpDQUJGRkI6MTBFNEUyNzo2OTZCODhDOCIsInZpc2l0b3JfaWQiOiIxODQ5MjYzMTQ1MzI2NzA4OTM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 90ca33bdc66a1d41c0d36a679d43166a6cbe5be4c48feb499bdd78d66c944990 |
| hovercard-subject-tag | issue:1698627316 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/104235/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12e4d3672fa72b798c1e071fba82e1617e8f0c15b2c0a0bd29ba261a1eb31221/python/cpython/issues/104235 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12e4d3672fa72b798c1e071fba82e1617e8f0c15b2c0a0bd29ba261a1eb31221/python/cpython/issues/104235 |
| og:image:alt | 3.12 documentation for enum.Enum.__dir__ says that this method returns "['__class__', '__doc__', '__module__', 'name', 'value'] and any public methods defined on self.__class__", but this is not tr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chgnrdv |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width