Title: functools.partialmethod not supported properly? · Issue #8619 · python/mypy · GitHub
Open Graph Title: functools.partialmethod not supported properly? · Issue #8619 · python/mypy
X Title: functools.partialmethod not supported properly? · Issue #8619 · python/mypy
Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy. import operator from functools import partialmethod class IntCmp: def __init__(self, value): self._value = value def _cmp...
Open Graph Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy. import operator from functools import partialmethod class IntCmp: def __init__(se...
X Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy. import operator from functools import partialmethod class IntCmp: def __init__(se...
Opengraph URL: https://github.com/python/mypy/issues/8619
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"functools.partialmethod not supported properly?","articleBody":"* Are you reporting a bug, or opening a feature request?\r\n\r\nBug\r\n\r\n* Please insert below the code you are checking with mypy.\r\n\r\n```py\r\nimport operator\r\nfrom functools import partialmethod\r\n\r\n\r\nclass IntCmp:\r\n def __init__(self, value):\r\n self._value = value\r\n\r\n def _cmp(self, opr, other: int) -> bool:\r\n if isinstance(other, int):\r\n return opr(self._value, other)\r\n return NotImplemented\r\n\r\n __eq__ = partialmethod(_cmp, operator.eq) # Incompatible types in assignment (expression has type \"partialmethod[bool]\", base class \"object\" defined the type as \"Callable[[object, object], bool]\")\r\n __ne__ = partialmethod(_cmp, operator.ne) # Incompatible types in assignment (expression has type \"partialmethod[bool]\", base class \"object\" defined the type as \"Callable[[object, object], bool]\")\r\n # rest of the comparison operators (lt, le, gt, ge) type checks correctly\r\n\r\n\r\nc = IntCmp(1)\r\nassert c == 1 # Cannot determine type of '__eq__'\r\n```\r\n\r\n* What is the actual behavior/output?\r\n\r\nMyPy reports an error on the comparison, saying `Cannot determine type of '__eq__'`, as well as incompatible types on assignment as shown.\r\nThe code correctly passes at runtime.\r\n\r\n* What is the behavior/output you expect?\r\n\r\n`__eq__` and `__ne__` should correctly type-check the `partialmethod`, and comparison should give no error. This particular `partialmethod` usage is shown in Python docs: https://docs.python.org/3/library/functools.html#functools.partialmethod\r\n\r\n* What are the versions of mypy and Python you are using?\r\n Do you see the same issue after installing mypy from Git master?\r\n\r\nUsing latest git master, Python 3.8.1\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n\r\n```\r\n--follow-imports=silent\r\n--show-column-numbers\r\n--ignore-missing-imports\r\n--check-untyped-defs\r\n```\r\n\r\nEDIT: I am aware of #2967 and #1484 being a thing, however this covers `partialmethod` usage which wasn't mentioned as a topic in the two other issues.","author":{"url":"https://github.com/DevilXD","@type":"Person","name":"DevilXD"},"datePublished":"2020-04-02T11:11:39Z","url":"https://github.com/python/mypy/issues/8619"}
| 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:5d5157b6-d65b-d5c7-322b-11a5602020a9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CAAC:184B81:2488ACB:2FA6538:6AFFF650 |
| html-safe-nonce | 00318d98542a6cc7edb23abe7009673896b370e97fbb4c7ff2cddcdf448726a7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUFDOjE4NEI4MToyNDg4QUNCOjJGQTY1Mzg6NkFGRkY2NTAiLCJ2aXNpdG9yX2lkIjoiMzQ5MTU3MDEyNDM2MjYxMDI1NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 10704cdddf3a363ab308261cab0825b58f20358b3a1542deec3755c62e3a8a0c |
| hovercard-subject-tag | issue:592549529 |
| 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/8619/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d4a8b086960a43f9e1c6fd2a0bea50a697f33a3c1887ddd330513cf1a61df86e/python/mypy/issues/8619 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d4a8b086960a43f9e1c6fd2a0bea50a697f33a3c1887ddd330513cf1a61df86e/python/mypy/issues/8619 |
| og:image:alt | Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy. import operator from functools import partialmethod class IntCmp: def __init__(se... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DevilXD |
| 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