Title: Check keyword argument compatibility across class hierarchies · Issue #1013 · python/mypy · GitHub
Open Graph Title: Check keyword argument compatibility across class hierarchies · Issue #1013 · python/mypy
X Title: Check keyword argument compatibility across class hierarchies · Issue #1013 · python/mypy
Description: Currently mypy doesn't check that a method override has keyword argument names that are compatible with the overridden method. The reason is that a lot of code doesn't define these names consistently, and mypy would generate a ton of use...
Open Graph Description: Currently mypy doesn't check that a method override has keyword argument names that are compatible with the overridden method. The reason is that a lot of code doesn't define these names consistent...
X Description: Currently mypy doesn't check that a method override has keyword argument names that are compatible with the overridden method. The reason is that a lot of code doesn't define these names co...
Opengraph URL: https://github.com/python/mypy/issues/1013
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Check keyword argument compatibility across class hierarchies","articleBody":"Currently mypy doesn't check that a method override has keyword argument names that are compatible with the overridden method. The reason is that a lot of code doesn't define these names consistently, and mypy would generate a ton of useless errors if it insisted on compatibility here. So mypy doesn't complain about this:\n\n```\nclass A:\n def f(self, x): ...\nclass B(A):\n def f(self, xx): ...\n```\n\nHowever, this means that calls via keyword arguments can fail at runtime:\n\n```\ndef f(a: A) -> None:\n a.f(x=1) # Failure if a is an instance of B\n\nf(B())\n```\n\nWe could do better than this: if we call a method `m` of `A` using a keyword argument `x`, we could verify that all methods `m` in the class hierarchy below `A` define the keyword argument `x`. So we'd only enforce this if some code actually depends on the keyword argument name. Mypy would then give a list of all classes that have an incompatible definition of `m` and explain why the code could go wrong. If a method is always called using positional arguments only, no errors would be reported.\n\nWe might want to give a warning instead of an error for this, as it could generate false positives.\n\nImplementing this would be fairly complicated as it would require access to _all_ subclasses of a given class. In practice, this could happen in a separate type checking pass that happens after the entire program has been type checked, but I'm not really sure what's the best way to implement this and whether this is useful enough to implement at all.\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2015-11-26T23:42:12Z","url":"https://github.com/python/mypy/issues/1013"}
| 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:6d481309-2d69-1995-84d4-c38fa10bebbc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A03C:2A0045:2EB857B:3DA4A15:6B002401 |
| html-safe-nonce | 8f52b9f8479de19f16e60bf53d8e7ef66ae659390ed30c711445d0b3f2368a57 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDNDOjJBMDA0NToyRUI4NTdCOjNEQTRBMTU6NkIwMDI0MDEiLCJ2aXNpdG9yX2lkIjoiNDQ3NjE0NTUyODE5NDczNzE1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 09438db4904d1066bc08b52376a7506593e7d350f10451ced1681ec2fb9dbc2c |
| hovercard-subject-tag | issue:119111108 |
| 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/1013/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fb04fcc806133d2868199cb8503093c142230b9f25fae10c8a0723cc1a5996a8/python/mypy/issues/1013 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fb04fcc806133d2868199cb8503093c142230b9f25fae10c8a0723cc1a5996a8/python/mypy/issues/1013 |
| og:image:alt | Currently mypy doesn't check that a method override has keyword argument names that are compatible with the overridden method. The reason is that a lot of code doesn't define these names consistent... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width