Title: Metaclass is not properly inherited when using multiple inheritance with int · Issue #2824 · python/mypy · GitHub
Open Graph Title: Metaclass is not properly inherited when using multiple inheritance with int · Issue #2824 · python/mypy
X Title: Metaclass is not properly inherited when using multiple inheritance with int · Issue #2824 · python/mypy
Description: Consider: class M(type): def foo(self): pass class C(metaclass=M): pass print(C.__class__) C.foo() class D(int, C): pass print(D.__class__) D.foo() Running this with Python 3 shows that D's metaclass is M, but when checking this with myp...
Open Graph Description: Consider: class M(type): def foo(self): pass class C(metaclass=M): pass print(C.__class__) C.foo() class D(int, C): pass print(D.__class__) D.foo() Running this with Python 3 shows that D's metacla...
X Description: Consider: class M(type): def foo(self): pass class C(metaclass=M): pass print(C.__class__) C.foo() class D(int, C): pass print(D.__class__) D.foo() Running this with Python 3 shows that D's met...
Opengraph URL: https://github.com/python/mypy/issues/2824
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Metaclass is not properly inherited when using multiple inheritance with int","articleBody":"Consider:\r\n```python\r\nclass M(type):\r\n def foo(self): pass\r\nclass C(metaclass=M):\r\n pass\r\nprint(C.__class__)\r\nC.foo()\r\nclass D(int, C):\r\n pass\r\nprint(D.__class__)\r\nD.foo()\r\n```\r\nRunning this with Python 3 shows that D's metaclass is M, but when checking this with mypy, we get the error\r\n```\r\nu.py:10: error: \"D\" has no attribute \"foo\"\r\n```\r\non the last line, showing that mypy doesn't believe so.\r\n\r\nThis seems unique to `int` (or perhaps builtin types?) -- when create a separate class `A` (without a metaclass) and use that instead of `int`, there is no error.\r\n\r\nFWIW this prevents me from fixing #2305 (iterating on enums) -- I can get it to work for Enum but not for IntEnum, because it multiply inherits from int and from Enum.","author":{"url":"https://github.com/gvanrossum","@type":"Person","name":"gvanrossum"},"datePublished":"2017-02-07T18:32:28Z","url":"https://github.com/python/mypy/issues/2824"}
| 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:cb031b8d-633e-f4a7-dfcf-2bf7e9cf0b24 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FE0:5314B:272F183:3342ACD:6B0003E0 |
| html-safe-nonce | db06cffac2721aefd0716f3bc43da096e59be3c54c03c8457a2ce2f91c7ebf14 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkUwOjUzMTRCOjI3MkYxODM6MzM0MkFDRDo2QjAwMDNFMCIsInZpc2l0b3JfaWQiOiI3ODk5MjA0Mzc2ODYwODIwNDQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dd69970813990328ba692067ab08010c891e333345d8fe49c23f8a9145abf3e1 |
| hovercard-subject-tag | issue:205975342 |
| 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/2824/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e99776b5d5618f5f0dba35b1cc0f3f8f47c5febbdff3d01c82ca611a9c314bf0/python/mypy/issues/2824 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e99776b5d5618f5f0dba35b1cc0f3f8f47c5febbdff3d01c82ca611a9c314bf0/python/mypy/issues/2824 |
| og:image:alt | Consider: class M(type): def foo(self): pass class C(metaclass=M): pass print(C.__class__) C.foo() class D(int, C): pass print(D.__class__) D.foo() Running this with Python 3 shows that D's metacla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gvanrossum |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width