Title: Frozen dataclass with function fields incorrectly thinks first argument is self · Issue #10711 · python/mypy · GitHub
Open Graph Title: Frozen dataclass with function fields incorrectly thinks first argument is self · Issue #10711 · python/mypy
X Title: Frozen dataclass with function fields incorrectly thinks first argument is self · Issue #10711 · python/mypy
Description: Example from #5485 works with mypy 0.902 from dataclasses import dataclass from typing import Callable @dataclass class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" == r.fn(1) but let's change the dataclass to a frozen o...
Open Graph Description: Example from #5485 works with mypy 0.902 from dataclasses import dataclass from typing import Callable @dataclass class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" == r.fn(1) but ...
X Description: Example from #5485 works with mypy 0.902 from dataclasses import dataclass from typing import Callable @dataclass class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" == r....
Opengraph URL: https://github.com/python/mypy/issues/10711
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Frozen dataclass with function fields incorrectly thinks first argument is self","articleBody":"Example from #5485 works with mypy 0.902\r\n\r\n```\r\nfrom dataclasses import dataclass\r\nfrom typing import Callable\r\n\r\n@dataclass\r\nclass Repro:\r\n fn: Callable[[int], str]\r\n\r\nr = Repro(fn=repr)\r\nassert \"1\" == r.fn(1)\r\n```\r\n\r\nbut let's change the dataclass to a frozen one\r\n\r\n```\r\nfrom dataclasses import dataclass\r\nfrom typing import Callable\r\n\r\n@dataclass(frozen=True)\r\nclass Repro:\r\n fn: Callable[[int], str]\r\n\r\nr = Repro(fn=repr)\r\nassert \"1\" == r.fn(1)\r\n```\r\n\r\nthen\r\n\r\n```\r\n$ mypy t.py\r\nt.py:9: error: Invalid self argument \"Repro\" to attribute function \"fn\" with type \"Callable[[int], str]\"\r\nt.py:9: error: \"str\" not callable\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```","author":{"url":"https://github.com/wrobell","@type":"Person","name":"wrobell"},"datePublished":"2021-06-25T09:21:27Z","url":"https://github.com/python/mypy/issues/10711"}
| 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:dccbea19-6ee5-315e-fb82-8711f27156d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8382:49D53:52D74F:70C85C:6AFFF823 |
| html-safe-nonce | 7869733487ea6f41ad4d9240359d4a639890a154d45f597c8d9798933fba38d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzgyOjQ5RDUzOjUyRDc0Rjo3MEM4NUM6NkFGRkY4MjMiLCJ2aXNpdG9yX2lkIjoiODE0MTA3NDc0NzE3MDQ4NjMwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 90096bb41e72ad17e910c9c91483d0ffd1e7622d802d1331ae2431364853773f |
| hovercard-subject-tag | issue:929998918 |
| 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/10711/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b4660ad972a098425c8d02a9b0ed510ac96c6e264fd5756fce11ab4ff0208962/python/mypy/issues/10711 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b4660ad972a098425c8d02a9b0ed510ac96c6e264fd5756fce11ab4ff0208962/python/mypy/issues/10711 |
| og:image:alt | Example from #5485 works with mypy 0.902 from dataclasses import dataclass from typing import Callable @dataclass class Repro: fn: Callable[[int], str] r = Repro(fn=repr) assert "1" == r.fn(1) but ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wrobell |
| 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