Title: Only concrete class can be decorated with @total_ordering · Issue #8539 · python/mypy · GitHub
Open Graph Title: Only concrete class can be decorated with @total_ordering · Issue #8539 · python/mypy
X Title: Only concrete class can be decorated with @total_ordering · Issue #8539 · python/mypy
Description: When I check this code with mypy: from abc import abstractmethod from functools import total_ordering @total_ordering class PriorityMixin: @abstractmethod def getName(self) -> str: ... @abstractmethod def getPriority(self) -> int: ... de...
Open Graph Description: When I check this code with mypy: from abc import abstractmethod from functools import total_ordering @total_ordering class PriorityMixin: @abstractmethod def getName(self) -> str: ... @abstractmet...
X Description: When I check this code with mypy: from abc import abstractmethod from functools import total_ordering @total_ordering class PriorityMixin: @abstractmethod def getName(self) -> str: ... @abstract...
Opengraph URL: https://github.com/python/mypy/issues/8539
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Only concrete class can be decorated with @total_ordering","articleBody":"When I check this code with mypy:\r\n\r\n```py\r\nfrom abc import abstractmethod\r\nfrom functools import total_ordering\r\n\r\n@total_ordering\r\nclass PriorityMixin:\r\n\r\n @abstractmethod\r\n def getName(self) -> str: ...\r\n\r\n @abstractmethod\r\n def getPriority(self) -> int: ...\r\n\r\n def __hash__(self) -> int:\r\n return hash(self.getName())\r\n\r\n def __eq__(self, other: object) -> bool:\r\n if isinstance(other, PriorityMixin):\r\n return self.getName() == other.getName()\r\n else:\r\n return NotImplemented\r\n\r\n def __lt__(self, other: object) -> bool:\r\n if isinstance(other, PriorityMixin):\r\n prioCmp = self.getPriority() - other.getPriority()\r\n if prioCmp == 0:\r\n return self.getName() \u003c other.getName()\r\n else:\r\n return prioCmp \u003c 0\r\n else:\r\n return NotImplemented\r\n```\r\n\r\nIt reports:\r\n\r\n```\r\ntestcase.py:4: error: Only concrete class can be given where \"Type[PriorityMixin]\" is expected [misc]\r\n @total_ordering\r\n ^\r\n```\r\n\r\nI'm using mypy 0.770 under Python 3.7.3 on openSUSE Linux.\r\n\r\nI don't see a reason why an abstract class cannot be decorated with `@total_ordering`.\r\n\r\nIn [typeshed commit e404e15](https://github.com/python/typeshed/commit/e404e1592d8e1de9099c2dabc9fdb0e55c2d2070) the signature of `total_ordering` was changed to preserve the original type. I think that change makes sense until full `total_ordering` support is implemented (#4610), but it does trigger the issue described above.\r\n\r\nI think this issue may be a variation of #5374, since that describes a similar problem when using `@dataclass` as an annotation.\r\n\r\n","author":{"url":"https://github.com/mthuurne","@type":"Person","name":"mthuurne"},"datePublished":"2020-03-14T13:50:11Z","url":"https://github.com/python/mypy/issues/8539"}
| 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:3a494a10-4e66-cf90-e4b8-bd8785742506 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C380:308D9D:2363BAC:303F916:6B002FCF |
| html-safe-nonce | a742de7eb473a505fca4a9f48a71a82ee1c5c03c9560758062f9900d05f1f469 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzgwOjMwOEQ5RDoyMzYzQkFDOjMwM0Y5MTY6NkIwMDJGQ0YiLCJ2aXNpdG9yX2lkIjoiNzAyNDI1MTM5OTAwOTQ4MDY1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a2c4cc20323e2ff6def33784e688b23721536ae03541708afad5276abacc7d11 |
| hovercard-subject-tag | issue:581217474 |
| 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/8539/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ad80c2fc9ef714b644acbc4cd764e8f790cc1ba3f8cc224f060659f943abcdc/python/mypy/issues/8539 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ad80c2fc9ef714b644acbc4cd764e8f790cc1ba3f8cc224f060659f943abcdc/python/mypy/issues/8539 |
| og:image:alt | When I check this code with mypy: from abc import abstractmethod from functools import total_ordering @total_ordering class PriorityMixin: @abstractmethod def getName(self) -> str: ... @abstractmet... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mthuurne |
| 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