Title: Callable attribute is considered a method · Issue #9489 · python/mypy · GitHub
Open Graph Title: Callable attribute is considered a method · Issue #9489 · python/mypy
X Title: Callable attribute is considered a method · Issue #9489 · python/mypy
Description: Small example to illustrate the issue: import typing as t from dataclasses import dataclass, field @dataclass class Example: a: t.Callable[[], int] = field(default=lambda: 42) def call_a(self) -> None: self.a() # Attribute function "a" w...
Open Graph Description: Small example to illustrate the issue: import typing as t from dataclasses import dataclass, field @dataclass class Example: a: t.Callable[[], int] = field(default=lambda: 42) def call_a(self) -> N...
X Description: Small example to illustrate the issue: import typing as t from dataclasses import dataclass, field @dataclass class Example: a: t.Callable[[], int] = field(default=lambda: 42) def call_a(self) ->...
Opengraph URL: https://github.com/python/mypy/issues/9489
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Callable attribute is considered a method","articleBody":"Small example to illustrate the issue:\r\n\r\n```py\r\nimport typing as t\r\nfrom dataclasses import dataclass, field\r\n\r\n@dataclass\r\nclass Example:\r\n a: t.Callable[[], int] = field(default=lambda: 42)\r\n\r\n def call_a(self) -> None:\r\n self.a() # Attribute function \"a\" with type \"Callable[[], int]\" does not accept self argument\r\n```\r\n\r\nCuriously, adding `Example` as the first argument to the type of `a` makes the call be recognized OK but the default not.\r\n\r\n```py\r\nfrom typing import t\r\nfrom dataclasses import dataclass, field\r\n\r\n@dataclass\r\nclass Example:\r\n a: t.Callable[['Example'], int] = field(default=lambda: 42) # Incompatible types in assignment (expression has type \"Callable[[], int]\", variable has type \"Callable[[Example], int]\")\r\n\r\n def call_a(self):\r\n self.a()\r\n```\r\n\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: mypy 0.782\r\n- Mypy command-line flags:\r\n- Mypy configuration options from `mypy.ini` (and other config files): \r\n- Python version used: 3.7\r\n- Operating system and version: Debian WSL\r\n\r\n\u003c!--\r\nYou can freely edit this text, please remove all the lines\r\nyou believe are unnecessary.\r\n-->\r\n","author":{"url":"https://github.com/NiklasRosenstein","@type":"Person","name":"NiklasRosenstein"},"datePublished":"2020-09-25T22:04:08Z","url":"https://github.com/python/mypy/issues/9489"}
| 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:2261c68d-104d-dd04-f3ee-d58e0f7bc783 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B21C:2F2EB9:24D65F8:302E2A6:6AFFF7DE |
| html-safe-nonce | 94418193f3e609ba96bb43be124d20ed45d5c947dead0f91b4a045292a688364 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjFDOjJGMkVCOToyNEQ2NUY4OjMwMkUyQTY6NkFGRkY3REUiLCJ2aXNpdG9yX2lkIjoiNjI4ODA2NTIxMTAxNDMxMzk1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 78ef39aec6bedba7c91e58be77ae995effe5e2897761c3fbf394b219b4b3b639 |
| hovercard-subject-tag | issue:709310004 |
| 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/9489/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b13f75e13a476f1bf8596b8c52342b94517cd8949433295fcd02af091fcbdb5/python/mypy/issues/9489 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b13f75e13a476f1bf8596b8c52342b94517cd8949433295fcd02af091fcbdb5/python/mypy/issues/9489 |
| og:image:alt | Small example to illustrate the issue: import typing as t from dataclasses import dataclass, field @dataclass class Example: a: t.Callable[[], int] = field(default=lambda: 42) def call_a(self) -> N... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NiklasRosenstein |
| 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