Title: `unreachable` false positive when using `isinstance` on class with `__call__` when function parameter uses `ParamSpec` · Issue #16024 · python/mypy · GitHub
Open Graph Title: `unreachable` false positive when using `isinstance` on class with `__call__` when function parameter uses `ParamSpec` · Issue #16024 · python/mypy
X Title: `unreachable` false positive when using `isinstance` on class with `__call__` when function parameter uses `ParamSpec` · Issue #16024 · python/mypy
Description: from typing import Callable, ParamSpec P = ParamSpec("P") class Foo: def __call__(self) -> None: ... def foo(fn: Callable[P, None]) -> None: if isinstance(fn, Foo): print("reached") # error: Statement is unreachable [unreachable] foo(Foo...
Open Graph Description: from typing import Callable, ParamSpec P = ParamSpec("P") class Foo: def __call__(self) -> None: ... def foo(fn: Callable[P, None]) -> None: if isinstance(fn, Foo): print("reached") # error: Statem...
X Description: from typing import Callable, ParamSpec P = ParamSpec("P") class Foo: def __call__(self) -> None: ... def foo(fn: Callable[P, None]) -> None: if isinstance(fn, Foo): print("reac...
Opengraph URL: https://github.com/python/mypy/issues/16024
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`unreachable` false positive when using `isinstance` on class with `__call__` when function parameter uses `ParamSpec`","articleBody":"```py\r\nfrom typing import Callable, ParamSpec\r\n\r\nP = ParamSpec(\"P\")\r\n\r\n\r\nclass Foo:\r\n def __call__(self) -> None:\r\n ...\r\n\r\n\r\ndef foo(fn: Callable[P, None]) -> None:\r\n if isinstance(fn, Foo):\r\n print(\"reached\") # error: Statement is unreachable [unreachable]\r\n\r\n\r\nfoo(Foo())\r\n```\r\n[playground](https://mypy-play.net/?mypy=latest&python=3.10&flags=show-error-context%2Cshow-error-codes%2Cstrict%2Ccheck-untyped-defs%2Cdisallow-any-decorated%2Cdisallow-any-expr%2Cdisallow-any-explicit%2Cdisallow-any-generics%2Cdisallow-any-unimported%2Cdisallow-incomplete-defs%2Cdisallow-subclassing-any%2Cdisallow-untyped-calls%2Cdisallow-untyped-decorators%2Cdisallow-untyped-defs%2Cno-implicit-reexport%2Clocal-partial-types%2Cstrict-equality%2Cwarn-incomplete-stub%2Cwarn-redundant-casts%2Cwarn-return-any%2Cwarn-unreachable%2Cwarn-unused-configs%2Cwarn-unused-ignores%2Cno-implicit-optional&gist=286f89279cc0211624590bb6e5ffbf0f)\r\n\r\nin this example, that line is always reached at runtime","author":{"url":"https://github.com/DetachHead","@type":"Person","name":"DetachHead"},"datePublished":"2023-09-03T04:22:34Z","url":"https://github.com/python/mypy/issues/16024"}
| 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:682d9bc1-0ccd-3a14-6077-0067d186bd42 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C40:D33AC:3B3B37:4FD22D:6B002A1F |
| html-safe-nonce | da56b5135c6440351f2f1f747f1e009843aebbb7581b1d728fde88edb8ee4a17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzQwOkQzM0FDOjNCM0IzNzo0RkQyMkQ6NkIwMDJBMUYiLCJ2aXNpdG9yX2lkIjoiNjY2ODY5NDIwNTQyNDA1MTUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 20e13810d1e4acad09daea67092cea32a1f27b3dafdc72bff5c2c1fc95635d18 |
| hovercard-subject-tag | issue:1878929494 |
| 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/16024/issue_layout |
| twitter:image | https://opengraph.githubassets.com/868b8c2561577b3353b89fa470d4f98e733143551fb80b3bc18655083d1de755/python/mypy/issues/16024 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/868b8c2561577b3353b89fa470d4f98e733143551fb80b3bc18655083d1de755/python/mypy/issues/16024 |
| og:image:alt | from typing import Callable, ParamSpec P = ParamSpec("P") class Foo: def __call__(self) -> None: ... def foo(fn: Callable[P, None]) -> None: if isinstance(fn, Foo): print("reached") # error: Statem... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DetachHead |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width