Title: `MethodType` uses `FunctionLike` types inconsistently · Issue #11200 · python/typeshed · GitHub
Open Graph Title: `MethodType` uses `FunctionLike` types inconsistently · Issue #11200 · python/typeshed
X Title: `MethodType` uses `FunctionLike` types inconsistently · Issue #11200 · python/typeshed
Description: Since version 1.8, Mypy does not intersect types in isinstance checks if at least one is final. In my code base, this leads to unexpected unreachable warnings. I could narrow them down to: from types import MethodType m: MethodType if is...
Open Graph Description: Since version 1.8, Mypy does not intersect types in isinstance checks if at least one is final. In my code base, this leads to unexpected unreachable warnings. I could narrow them down to: from typ...
X Description: Since version 1.8, Mypy does not intersect types in isinstance checks if at least one is final. In my code base, this leads to unexpected unreachable warnings. I could narrow them down to: from typ...
Opengraph URL: https://github.com/python/typeshed/issues/11200
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`MethodType` uses `FunctionLike` types inconsistently","articleBody":"Since version 1.8, Mypy [does not intersect types in isinstance checks if at least one is final](https://github.com/python/mypy/pull/16330). In my code base, this leads to unexpected unreachable warnings. I could narrow them down to:\r\n\r\n```python\r\nfrom types import MethodType\r\n\r\nm: MethodType\r\nif isinstance(m.__func__, MethodType): # error: Subclass of \"FunctionType\" and \"MethodType\" cannot exist: \"FunctionType\" is final [unreachable] \\\r\n # error: Subclass of \"FunctionType\" and \"MethodType\" cannot exist: \"MethodType\" is final [unreachable]\r\n m = m.__func__ # error: Statement is unreachable [unreachable]\r\n```\r\n\r\nAs I implemented the Mypy change, I double-checked that I did not break something. But it seems the definition of `MethodType` in typeshed is inconsistent. Its `__init__` method accepts `Callable` (#1499), but its `__func__` attribute returns `FunctionType` (#1383). As `MethodType` can accept and return other methods at runtime, it seems right to define the return type as `Callable`, too.","author":{"url":"https://github.com/tyralla","@type":"Person","name":"tyralla"},"datePublished":"2023-12-26T09:41:06Z","url":"https://github.com/python/typeshed/issues/11200"}
| 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:46a2aadf-d8f2-c614-d4b3-289664effefd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C3A:178BB9:14C6855:1AA3FAF:6AFFA541 |
| html-safe-nonce | 1b5c37d6d99a3a1ef0a756e92ddfe1798049e6e1ed2e2e2533f5c386653c2e3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzNBOjE3OEJCOToxNEM2ODU1OjFBQTNGQUY6NkFGRkE1NDEiLCJ2aXNpdG9yX2lkIjoiNjc3MDU2OTg2MDA0NTg0MTcyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | efb086a25fbbb75675018999ad6198c9fdeb5610a9171ac1fbb9da7ef52974cf |
| hovercard-subject-tag | issue:2056233807 |
| 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/typeshed/11200/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2d837df0a176aa11cec5f9dee96479a82e0b57c39161c907348b61955fc54ae8/python/typeshed/issues/11200 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2d837df0a176aa11cec5f9dee96479a82e0b57c39161c907348b61955fc54ae8/python/typeshed/issues/11200 |
| og:image:alt | Since version 1.8, Mypy does not intersect types in isinstance checks if at least one is final. In my code base, this leads to unexpected unreachable warnings. I could narrow them down to: from typ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tyralla |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba28afc7a27af7a823370a957c9e2c39d10289886a55f1d91350f367020c25ca |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 72f549919f17231189a8ff5726b8003c72c7eb99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width