Title: `.enum_members` property does not account to `@member` decorator and call · Issue #18557 · python/mypy · GitHub
Open Graph Title: `.enum_members` property does not account to `@member` decorator and call · Issue #18557 · python/mypy
X Title: `.enum_members` property does not account to `@member` decorator and call · Issue #18557 · python/mypy
Description: Code in question: mypy/mypy/nodes.py Lines 3232 to 3243 in 93d1ce4 @property def enum_members(self) -> list[str]: return [ name for name, sym in self.names.items() if ( isinstance(sym.node, Var) and name not in EXCLUDED_ENUM_ATTRIBUTES a...
Open Graph Description: Code in question: mypy/mypy/nodes.py Lines 3232 to 3243 in 93d1ce4 @property def enum_members(self) -> list[str]: return [ name for name, sym in self.names.items() if ( isinstance(sym.node, Var) an...
X Description: Code in question: mypy/mypy/nodes.py Lines 3232 to 3243 in 93d1ce4 @property def enum_members(self) -> list[str]: return [ name for name, sym in self.names.items() if ( isinstance(sym.node, Var)...
Opengraph URL: https://github.com/python/mypy/issues/18557
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`.enum_members` property does not account to `@member` decorator and call","articleBody":"Code in question: https://github.com/python/mypy/blob/93d1ce4133467a84b02ea06e5936cf6480afe08f/mypy/nodes.py#L3232-L3243\n\nThis is a problem, because methods decorated as `@member` are not included into the members list.\n\nThe simplest repro where this is a problem:\n\n```python\nfrom enum import Enum, member\nfrom typing import reveal_type\n\nclass Pet(Enum):\n CAT = 1\n\n @member\n def human(self) -> int:\n return 2\n\ndef a(x: Pet) -> None:\n if x is not Pet.CAT:\n reveal_type(x) \n```\n\nWith `--warn-unreachable` it will produce:\n\n```\nex.py:13: note: Revealed type is \"enum.member[def (self: ex.Pet) -> builtins.int]\"\nex.py:18: error: Statement is unreachable [unreachable]\n```\n\nBecause `.enum_members` here will only contain `CAT`: https://github.com/python/mypy/blob/93d1ce4133467a84b02ea06e5936cf6480afe08f/mypy/typeops.py#L974-L978\n\nI will send a PR with the fix.","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2025-01-28T11:50:53Z","url":"https://github.com/python/mypy/issues/18557"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:ee8881bf-0945-c161-eed6-191036e7650b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3AC:3A13A0:235AEAB:2FF8B9F:6B002C92 |
| html-safe-nonce | 30ac987d9356a6aa2305be080bc0fc9f4b6231ce73cbf9c4c9b93098208ed9ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0FDOjNBMTNBMDoyMzVBRUFCOjJGRjhCOUY6NkIwMDJDOTIiLCJ2aXNpdG9yX2lkIjoiNTk3NjY1NjgxMTkyMTUxNzcxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fb97ce6e350e940be1f53cf0450f63034a1ae9c4620d098c12526a2f4a844944 |
| hovercard-subject-tag | issue:2815417319 |
| 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/mypy/18557/issue_layout |
| twitter:image | https://opengraph.githubassets.com/67fc76c5625b84d1cba7f784a7008a57aa9e78c1534556c9ff6208608bf40618/python/mypy/issues/18557 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/67fc76c5625b84d1cba7f784a7008a57aa9e78c1534556c9ff6208608bf40618/python/mypy/issues/18557 |
| og:image:alt | Code in question: mypy/mypy/nodes.py Lines 3232 to 3243 in 93d1ce4 @property def enum_members(self) -> list[str]: return [ name for name, sym in self.names.items() if ( isinstance(sym.node, Var) an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width