Title: enum.Flag ignores bitwise operator methods from mixins · Issue #121291 · python/cpython · GitHub
Open Graph Title: enum.Flag ignores bitwise operator methods from mixins · Issue #121291 · python/cpython
X Title: enum.Flag ignores bitwise operator methods from mixins · Issue #121291 · python/cpython
Description: When I define methods ('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__') directly in the class inheriting from enum.Flag, these methods are "added" (mro) to the members, however, if the method is defined in...
Open Graph Description: When I define methods ('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__') directly in the class inheriting from enum.Flag, these methods are "added" (mro) to the membe...
X Description: When I define methods ('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__') directly in the class inheriting from...
Opengraph URL: https://github.com/python/cpython/issues/121291
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"enum.Flag ignores bitwise operator methods from mixins","articleBody":"When I define methods `('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__')`\r\ndirectly in the class inheriting from `enum.Flag`, these methods are \"added\" (mro) to the members, however, if the method is defined in the mixin, the methods defined in `enum.Flag` are added (e.g. `Flag.__or__`). I would expect methods to be called from mixin.\r\n\r\n```py\r\nfrom enum import Flag\r\n\r\n\r\nclass Mixin:\r\n def __or__(self, value): ...\r\n\r\n\r\nclass MyFlag(Mixin, Flag):\r\n pass\r\n\r\n\r\nclass MyFlag2(Flag):\r\n def __or__(self, value): ...\r\n\r\n\r\nprint(MyFlag.__or__.__qualname__) # Flag.__or__, I would expect Mixin.__or__\r\nprint(MyFlag2.__or__.__qualname__) # MyFlag2.__or__ - GOOD\r\n```\r\n\r\nhttps://github.com/python/cpython/blob/089835469d5efbea4793cd611b43cb8387f2e7e5/Lib/enum.py#L610-L619\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155862\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gswifort","@type":"Person","name":"gswifort"},"datePublished":"2024-07-02T20:06:35Z","url":"https://github.com/python/cpython/issues/121291"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:5989470e-e18d-db2b-440e-9bf61c10c2ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE86:264FC7:3CCF47:531150:6AED17AD |
| html-safe-nonce | 1b4beba29dd68c832c97d91ea889d7d0865667db497d322da6949f58c9e5e380 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTg2OjI2NEZDNzozQ0NGNDc6NTMxMTUwOjZBRUQxN0FEIiwidmlzaXRvcl9pZCI6IjIxMjYzNTkxNjY2ODExNTk1OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 99f1480acb8a596fa44761c2f9f82af194396c348e07fe6d08682600cfa155f3 |
| hovercard-subject-tag | issue:2387065577 |
| 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/121291/issue_layout |
| twitter:image | https://opengraph.githubassets.com/18d6c9d7cca5dcf1ef136c0637ffe04853608e5a906186f77db4d3fb86214678/python/cpython/issues/121291 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/18d6c9d7cca5dcf1ef136c0637ffe04853608e5a906186f77db4d3fb86214678/python/cpython/issues/121291 |
| og:image:alt | When I define methods ('__or__', '__and__', '__xor__', '__ror__', '__rand__', '__rxor__', '__invert__') directly in the class inheriting from enum.Flag, these methods are "added" (mro) to the membe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gswifort |
| hostname | github.com |
| expected-hostname | github.com |
| None | 120085d0bcec1f427e3ab45302c8b95f873d26ad21984dc86d62ab2c10158f41 |
| 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 | e12fd03aa775dceadc5a793c3a0791e43ca256bb |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width