Title: False positive for class patterns when `Callable` is used · Issue #16617 · python/mypy · GitHub
Open Graph Title: False positive for class patterns when `Callable` is used · Issue #16617 · python/mypy
X Title: False positive for class patterns when `Callable` is used · Issue #16617 · python/mypy
Description: Mypy generates a false positive with the following code. from collections.abc import Callable from typing import TypeVar T = TypeVar("T") def foo(obj: T | Callable[..., T]) -> None: match obj: case Callable() as func: # error: Expected t...
Open Graph Description: Mypy generates a false positive with the following code. from collections.abc import Callable from typing import TypeVar T = TypeVar("T") def foo(obj: T | Callable[..., T]) -> None: match obj: case...
X Description: Mypy generates a false positive with the following code. from collections.abc import Callable from typing import TypeVar T = TypeVar("T") def foo(obj: T | Callable[..., T]) -> None: ma...
Opengraph URL: https://github.com/python/mypy/issues/16617
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positive for class patterns when `Callable` is used","articleBody":"Mypy generates a false positive with the following code.\r\n\r\n```python\r\nfrom collections.abc import Callable\r\nfrom typing import TypeVar\r\n\r\nT = TypeVar(\"T\")\r\n\r\ndef foo(obj: T | Callable[..., T]) -> None:\r\n match obj:\r\n case Callable() as func: # error: Expected type in class pattern; found \"typing._SpecialForm\"\r\n func()\r\n```\r\n\r\nFWIW, [pyright](https://github.com/microsoft/pyright/issues/6648) was also not handling this case correctly.\r\n\r\n\r\n","author":{"url":"https://github.com/erictraut","@type":"Person","name":"erictraut"},"datePublished":"2023-12-05T02:42:28Z","url":"https://github.com/python/mypy/issues/16617"}
| 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:38e4a666-ca32-cf34-7d34-9147bd005c41 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8036:1DF7D7:1DFC27:29DBF6:6B005702 |
| html-safe-nonce | c2d07d1c26bc0090fcc0c672163234962fc65f69bfcf1da0bd201b24d4889229 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDM2OjFERjdENzoxREZDMjc6MjlEQkY2OjZCMDA1NzAyIiwidmlzaXRvcl9pZCI6IjMwNzM4MDc2NTc3MzIxNjc0MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ea5af4149392dd1a186a9ab8e8d4aaffb65d979cb9884f199889a7c096e92c21 |
| hovercard-subject-tag | issue:2025163600 |
| 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/16617/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f304382d4a0f45af401454b858b8f06793a2a598b30cda4e48a748733d2883f/python/mypy/issues/16617 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f304382d4a0f45af401454b858b8f06793a2a598b30cda4e48a748733d2883f/python/mypy/issues/16617 |
| og:image:alt | Mypy generates a false positive with the following code. from collections.abc import Callable from typing import TypeVar T = TypeVar("T") def foo(obj: T | Callable[..., T]) -> None: match obj: case... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erictraut |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width