Title: False positives when overriding attributes in superclasses defined with function definitions · Issue #17513 · python/mypy · GitHub
Open Graph Title: False positives when overriding attributes in superclasses defined with function definitions · Issue #17513 · python/mypy
X Title: False positives when overriding attributes in superclasses defined with function definitions · Issue #17513 · python/mypy
Description: Bug Report, To Reproduce, & Actual Behaviour When overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function definition type itself, instead of the enti...
Open Graph Description: Bug Report, To Reproduce, & Actual Behaviour When overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function def...
X Description: Bug Report, To Reproduce, & Actual Behaviour When overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function...
Opengraph URL: https://github.com/python/mypy/issues/17513
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positives when overriding attributes in superclasses defined with function definitions","articleBody":"**Bug Report, To Reproduce, & Actual Behaviour**\r\n\r\nWhen overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function definition type itself, instead of the entire statement (that is, with all the decorators applied). See [mypy Playground](https://mypy-play.net/?mypy=latest&python=3.12&gist=6f40f97e2c7bd4821bfd1af843fb9736):\r\n\r\n```python\r\nclass A:\r\n @str\r\n def attr(self, /) -> None: ...\r\n\r\nclass B(A):\r\n attr: str # mypy: Incompatible types in assignment (expression has type \"str\", base class \"A\" defined the type as \"Callable[[A], None]\") [assignment]\r\n```\r\n\r\nThis is an artificial but minimum example; the actual use case is for a custom descriptor which has similar flexibility to `builtins.property`, allowing declaration & definition with both decorators (like `@property`) and assignments (like `attr = property(...)`).\r\n\r\n**Expected Behavior**\r\n\r\nNo issues\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.10.1, master\r\n- Mypy command-line flags: None\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: 3.10, 3.12","author":{"url":"https://github.com/bzoracler","@type":"Person","name":"bzoracler"},"datePublished":"2024-07-10T08:58:15Z","url":"https://github.com/python/mypy/issues/17513"}
| 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:fbbd7de4-c174-8d4f-79ac-0f045fa24a80 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE46:160A87:D4BD04:11614C7:6AFFF85F |
| html-safe-nonce | 33c215bf0bdc76e544aaad356e22f4bcd1ea0eda2993cbe0f948ce190c69026d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTQ2OjE2MEE4NzpENEJEMDQ6MTE2MTRDNzo2QUZGRjg1RiIsInZpc2l0b3JfaWQiOiI1OTI2ODA3ODI4MDUxMjYxNTM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2bb074ad30e38aee3548f7c6b835381b4138d10890f76b7a463a80d0ee2b58e4 |
| hovercard-subject-tag | issue:2400163562 |
| 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/17513/issue_layout |
| twitter:image | https://opengraph.githubassets.com/371b5a08252b9e584877db09928ffef69bc78937e86d0dde2be1b9f1f9061b4b/python/mypy/issues/17513 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/371b5a08252b9e584877db09928ffef69bc78937e86d0dde2be1b9f1f9061b4b/python/mypy/issues/17513 |
| og:image:alt | Bug Report, To Reproduce, & Actual Behaviour When overriding an attribute created with a function definition statement in the superclass, subclasses complain about type mismatch of the function def... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bzoracler |
| 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