Title: Class with attribute function thinks first argument is self · Issue #10353 · python/mypy · GitHub
Open Graph Title: Class with attribute function thinks first argument is self · Issue #10353 · python/mypy
X Title: Class with attribute function thinks first argument is self · Issue #10353 · python/mypy
Description: Bug Report I find this very similar to issue #5485. I found myself using this flavor of idiom so as to not repeat myself when implementing comparison operations, etc. To Reproduce from operator import itemgetter class A: id_getter = item...
Open Graph Description: Bug Report I find this very similar to issue #5485. I found myself using this flavor of idiom so as to not repeat myself when implementing comparison operations, etc. To Reproduce from operator imp...
X Description: Bug Report I find this very similar to issue #5485. I found myself using this flavor of idiom so as to not repeat myself when implementing comparison operations, etc. To Reproduce from operator imp...
Opengraph URL: https://github.com/python/mypy/issues/10353
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Class with attribute function thinks first argument is self","articleBody":"\u003c!--\r\n If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the \"Question and Help\" form\r\n instead.\r\n-->\r\n\r\n**Bug Report**\r\n\r\nI find this very similar to issue #5485. \r\n\r\nI found myself using this flavor of idiom so as to not repeat myself when implementing comparison operations, etc. \r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom operator import itemgetter\r\n\r\nclass A:\r\n id_getter = itemgetter('this', 'that', 'other')\r\n def __init__(self, d):\r\n self.d = d\r\n def __hash__(self) -> int:\r\n return hash(self.id_getter(self.d))\r\n\r\na = A({'this': 1, 'that': 2, 'other': 'a', 'extra': 'b'})\r\nhash(a)\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nNo error\r\n\r\n**Actual Behavior**\r\n\r\n```bash\r\n$ mypy example.py\r\nexample.py:8: error: Too many arguments\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nI tried to annotate `id_getter: ClassVar[Callable[[Dict], Tuple[int, int, str]]]` but just got back an additional error \r\n```\r\nexamply.py:8: error: Invalid self argument \"A\" to attribute function \"id_getter\" with type \"Callable[[Dict[Any, Any]], Tuple[Any, ...]]\"\r\n```\r\n\r\n**Your Environment**\r\n\r\n```bash\r\n$ mypy --version\r\nmypy 0.812\r\n```\r\nNo flags or ini file. ","author":{"url":"https://github.com/spagh-eddie","@type":"Person","name":"spagh-eddie"},"datePublished":"2021-04-22T00:58:14Z","url":"https://github.com/python/mypy/issues/10353"}
| 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:63520d82-ae11-2e86-e4ab-35db0f1c2b4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB08:30DBED:2707B16:32B5FCB:6AFFF7EA |
| html-safe-nonce | d489891ca7057b11ae2798e7250d12277bcdd6bad84dab3fe6534331da14960b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjA4OjMwREJFRDoyNzA3QjE2OjMyQjVGQ0I6NkFGRkY3RUEiLCJ2aXNpdG9yX2lkIjoiNTI3MjM1ODkxNzg1MzE0OTE2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 54eb81a77ab55f189336475305b90d1f6b5fa6e514ebde5cf1c0e559b71ea2f8 |
| hovercard-subject-tag | issue:864432231 |
| 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/10353/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df0f8b4165c9410dfe094b0bdb8254ad96c604209cd2093a53ccaf1295920e0d/python/mypy/issues/10353 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df0f8b4165c9410dfe094b0bdb8254ad96c604209cd2093a53ccaf1295920e0d/python/mypy/issues/10353 |
| og:image:alt | Bug Report I find this very similar to issue #5485. I found myself using this flavor of idiom so as to not repeat myself when implementing comparison operations, etc. To Reproduce from operator imp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | spagh-eddie |
| 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