Title: Clean up kludges for handling metaclasses and Type[...] in check_op_reversible · Issue #5491 · python/mypy · GitHub
Open Graph Title: Clean up kludges for handling metaclasses and Type[...] in check_op_reversible · Issue #5491 · python/mypy
X Title: Clean up kludges for handling metaclasses and Type[...] in check_op_reversible · Issue #5491 · python/mypy
Description: The current implementation for checking reversible operators contains two kludges that seem to be related to operators, metaclasses, and Type[...] This call to has_member feels like it ought to be unnecessary/redundant due to the followi...
Open Graph Description: The current implementation for checking reversible operators contains two kludges that seem to be related to operators, metaclasses, and Type[...] This call to has_member feels like it ought to be ...
X Description: The current implementation for checking reversible operators contains two kludges that seem to be related to operators, metaclasses, and Type[...] This call to has_member feels like it ought to be ...
Opengraph URL: https://github.com/python/mypy/issues/5491
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clean up kludges for handling metaclasses and Type[...] in check_op_reversible","articleBody":"The [current implementation for checking reversible operators][0] contains two kludges that seem to be related to operators, metaclasses, and Type[...]\r\n\r\n1. This call to [has_member][1] feels like it ought to be unnecessary/redundant due to the following `analyze_member_access` -- but removing it causes pythoneval's [OpMetaclassAccess](https://github.com/python/mypy/blob/master/test-data/unit/pythoneval.test#L1159) test case to fail.\r\n\r\n (Note: if you remove just that call, you also need to add in a `elif isinstance(member, AnyTyp): return None` after calling `analyze_member_access`)\r\n\r\n2. If the reversible operators logic was unable to find a matching operator, it just [tries calling `check_call` on the name directly][2] to get back some generic error message. It seems as if this call ought to always return an error message, but sometimes it surprisingly will not. E.g. see the [TypeTypeComparisonWorks](https://github.com/python/mypy/blob/master/test-data/unit/check-classes.test#L3251) tests in check-classes -- adding an `assert local_errors.is_errors()` causes that test case to crash.\r\n\r\n This feels related to the first TODO in some way -- either we're not handling operators + metaclasses + Type directly, or there are some weird shenanigans happening due to `Any`...\r\n\r\nFor additional context, see https://github.com/python/mypy/issues/5136 and https://github.com/python/mypy/pull/1806.\r\n\r\n [0]:https://github.com/python/mypy/blob/master/mypy/checkexpr.py#L1848\r\n [1]: https://github.com/python/mypy/blob/master/mypy/checkexpr.py#L1879\r\n [2]: https://github.com/python/mypy/blob/master/mypy/checkexpr.py#L2020","author":{"url":"https://github.com/Michael0x2a","@type":"Person","name":"Michael0x2a"},"datePublished":"2018-08-16T20:19:58Z","url":"https://github.com/python/mypy/issues/5491"}
| 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:7f02d5b3-80e2-f5cb-75d7-1aaedb4fd796 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D642:144E47:24F74CD:301CCB6:6AFFF26B |
| html-safe-nonce | 3e49f12f0e1be8d0185e3a98dd8f300fde4673adeebed3649bee61a29d1f2d74 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjQyOjE0NEU0NzoyNEY3NENEOjMwMUNDQjY6NkFGRkYyNkIiLCJ2aXNpdG9yX2lkIjoiNjc5MTA4NDkxNzM2NDA5MzU0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b81b8bcea58b8b42fd95485f8954c1c7a5f5c09a0f3f085593d888aee63a351e |
| hovercard-subject-tag | issue:351353825 |
| 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/5491/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bd40986b7c7ef5efc5630562d35e6001b16fc039ffa646fe6a8060cc1fa0c5ca/python/mypy/issues/5491 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bd40986b7c7ef5efc5630562d35e6001b16fc039ffa646fe6a8060cc1fa0c5ca/python/mypy/issues/5491 |
| og:image:alt | The current implementation for checking reversible operators contains two kludges that seem to be related to operators, metaclasses, and Type[...] This call to has_member feels like it ought to be ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Michael0x2a |
| 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