Title: Assignment through def does not satisfy ABC's Optional Callable with args · Issue #13194 · python/mypy · GitHub
Open Graph Title: Assignment through def does not satisfy ABC's Optional Callable with args · Issue #13194 · python/mypy
X Title: Assignment through def does not satisfy ABC's Optional Callable with args · Issue #13194 · python/mypy
Description: It is not possible to satisfy an ABC that has an Optional Callable with args defined using a "def" in the concrete class. A Callable which is not optional may be defined. An Optional Callable with no arguments may also be defined. Reprod...
Open Graph Description: It is not possible to satisfy an ABC that has an Optional Callable with args defined using a "def" in the concrete class. A Callable which is not optional may be defined. An Optional Callable with ...
X Description: It is not possible to satisfy an ABC that has an Optional Callable with args defined using a "def" in the concrete class. A Callable which is not optional may be defined. An Optional Call...
Opengraph URL: https://github.com/python/mypy/issues/13194
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assignment through def does not satisfy ABC's Optional Callable with args","articleBody":"_It is not possible to satisfy an ABC that has an Optional Callable with args defined using a \"def\" in the concrete class._\r\n\r\nA Callable which is not optional **may be defined**.\r\n\r\nAn Optional Callable with no arguments **may also be defined**.\r\n\r\n[Reproduction of the problem using mypy version 0.961 in the mypy playground](https://mypy-play.net/?mypy=latest&python=3.10&gist=45396e17da8fe4597efd74c67372fb26).\r\n\r\nThe cases `Two` and `Three` below should be accepted as suitable implementations of `check`, and they are not.\r\n\r\n```\r\nimport abc\r\nfrom typing import Callable, Optional\r\n\r\n# optional callable with an argument define\r\nclass OptCallArgs(abc.ABC):\r\n check: Optional[Callable[[int], None]]\r\n\r\n# assignment of a callable is fine\r\nclass One(OptCallArgs):\r\n check = lambda value: None\r\n\r\n# \"def\" of a suitable callable is not handled\r\nclass Two(OptCallArgs):\r\n @staticmethod\r\n def check(value: int): ...\r\n\r\nclass Three(OptCallArgs):\r\n def check(self, value: int): ...\r\n\r\n# callable with args has no issue\r\nclass CallArgs(abc.ABC):\r\n check: Callable[[int], None]\r\n\r\nclass Four(CallArgs):\r\n def check(self, value: int): ...\r\n\r\n# optional callable does not have an issue if there are no args\r\nclass OptCall(abc.ABC):\r\n check: Optional[Callable]\r\n\r\nclass Five(OptCall):\r\n def check(self): ...\r\n```\r\n","author":{"url":"https://github.com/r1chardj0n3s","@type":"Person","name":"r1chardj0n3s"},"datePublished":"2022-07-19T22:34:25Z","url":"https://github.com/python/mypy/issues/13194"}
| 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:00440f58-2885-acce-eab8-a452a1a5868a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9C2:1CF166:244D77B:3168B10:6B0033F6 |
| html-safe-nonce | f5c90c9f51e3597905f28aaa089f0f680e9bc29e13c4752e4e7badc988ef22fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUMyOjFDRjE2NjoyNDRENzdCOjMxNjhCMTA6NkIwMDMzRjYiLCJ2aXNpdG9yX2lkIjoiNTc1NDk3OTIyNjA1OTAyNzQ0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d2bc13f9bff85f41fbf5c8161e4a54d0ef7a88e5de20539916a6036b436d8719 |
| hovercard-subject-tag | issue:1310123096 |
| 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/13194/issue_layout |
| twitter:image | https://opengraph.githubassets.com/371b5a08252b9e584877db09928ffef69bc78937e86d0dde2be1b9f1f9061b4b/python/mypy/issues/13194 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/371b5a08252b9e584877db09928ffef69bc78937e86d0dde2be1b9f1f9061b4b/python/mypy/issues/13194 |
| og:image:alt | It is not possible to satisfy an ABC that has an Optional Callable with args defined using a "def" in the concrete class. A Callable which is not optional may be defined. An Optional Callable with ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | r1chardj0n3s |
| 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