Title: type checking of member assigned with lambda · Issue #13818 · python/mypy · GitHub
Open Graph Title: type checking of member assigned with lambda · Issue #13818 · python/mypy
X Title: type checking of member assigned with lambda · Issue #13818 · python/mypy
Description: Bug Report What this #13400 looks like it's supposed to fix is not working here. To Reproduce from typing import Callable class C: f: Callable[[int], bool] = staticmethod(lambda x: print(type(x)) or True) c = C() c.f(3) class D: f: Calla...
Open Graph Description: Bug Report What this #13400 looks like it's supposed to fix is not working here. To Reproduce from typing import Callable class C: f: Callable[[int], bool] = staticmethod(lambda x: print(type(x)) o...
X Description: Bug Report What this #13400 looks like it's supposed to fix is not working here. To Reproduce from typing import Callable class C: f: Callable[[int], bool] = staticmethod(lambda x: print(type(x...
Opengraph URL: https://github.com/python/mypy/issues/13818
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"type checking of member assigned with lambda","articleBody":"\r\n**Bug Report**\r\n\r\nWhat this https://github.com/python/mypy/pull/13400 looks like it's supposed to fix is not working here.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom typing import Callable\r\n\r\n\r\nclass C:\r\n f: Callable[[int], bool] = staticmethod(lambda x: print(type(x)) or True)\r\n\r\n\r\nc = C()\r\nc.f(3)\r\n\r\n\r\nclass D:\r\n f: Callable[[int], bool] = lambda x: print(type(x)) or True\r\n\r\n\r\nd = D()\r\nd.f(3)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nThe one that works correctly should not have a mypy error.\r\nThe one that doesn't work correctly should be found by mypy.\r\n\r\n**Actual Behavior**\r\n\r\nThe first one, class C, works correctly, but mypy says it's wrong.\r\noutput:\r\n```\r\n\u003cclass 'int'>\r\n```\r\nmypy:\r\n`Incompatible types in assignment (expression has type \"staticmethod[bool]\", variable has type \"Callable[[int], bool]\") [assignment]`\r\n\r\nThe second one, class D, fails, but mypy doesn't see any problem with it.\r\noutput:\r\n```\r\nTraceback (most recent call last):\r\n File ...\r\n d.f(3)\r\nTypeError: \u003clambda>() takes 1 positional argument but 2 were given\r\n```\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: 0.990+dev\r\n- Python version used: 3.8\r\n\r\n\u003c!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->\r\n","author":{"url":"https://github.com/beauxq","@type":"Person","name":"beauxq"},"datePublished":"2022-10-05T16:14:50Z","url":"https://github.com/python/mypy/issues/13818"}
| 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:16dfd45c-a26b-f271-2908-bda196d7d8dc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A2E6:43251:CA303F:109480B:6AFFF850 |
| html-safe-nonce | b1b7fb72951d24dcd39718557782ad7f32055051648bbc1df8c6f0881120d02a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkU2OjQzMjUxOkNBMzAzRjoxMDk0ODBCOjZBRkZGODUwIiwidmlzaXRvcl9pZCI6IjcwNzcxODkwOTE0MzA3NTg0ODAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 331b475d91baf6bc575836f7311a5a4cf910a86ca0cf1a076e5c99fdc2eef1b6 |
| hovercard-subject-tag | issue:1398049595 |
| 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/13818/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6ae69d74ef6d0ac445adbd0984c79eac1c46eb590fafa84250fa5de223166c8a/python/mypy/issues/13818 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6ae69d74ef6d0ac445adbd0984c79eac1c46eb590fafa84250fa5de223166c8a/python/mypy/issues/13818 |
| og:image:alt | Bug Report What this #13400 looks like it's supposed to fix is not working here. To Reproduce from typing import Callable class C: f: Callable[[int], bool] = staticmethod(lambda x: print(type(x)) o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | beauxq |
| 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