Title: Calling `callable` in an if-condition makes mypy think branch in unreachable · Issue #3605 · python/mypy · GitHub
Open Graph Title: Calling `callable` in an if-condition makes mypy think branch in unreachable · Issue #3605 · python/mypy
X Title: Calling `callable` in an if-condition makes mypy think branch in unreachable · Issue #3605 · python/mypy
Description: In the following code, mypy thinking callable(o) always returns False. This might be related to #3603. def f(o: object) -> None: if callable(o): # this branch is not typechecked o() 1 + 'boom' # no error from mypy o() f(lambda: print('he...
Open Graph Description: In the following code, mypy thinking callable(o) always returns False. This might be related to #3603. def f(o: object) -> None: if callable(o): # this branch is not typechecked o() 1 + 'boom' # no...
X Description: In the following code, mypy thinking callable(o) always returns False. This might be related to #3603. def f(o: object) -> None: if callable(o): # this branch is not typechecked o() 1 + 'boo...
Opengraph URL: https://github.com/python/mypy/issues/3605
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Calling `callable` in an if-condition makes mypy think branch in unreachable","articleBody":"In the following code, mypy thinking `callable(o)` always returns `False`. This might be related to #3603. \r\n```py\r\ndef f(o: object) -> None:\r\n if callable(o):\r\n # this branch is not typechecked\r\n o()\r\n 1 + 'boom' # no error from mypy\r\n o()\r\n\r\nf(lambda: print('hello'))\r\n```\r\n\r\nHere is the output from `mypy` and `python`.\r\n```\r\n$ mypy n.py \r\n$ python3 n.py \r\nhello\r\nTraceback (most recent call last):\r\n File \"n.py\", line 8, in \u003cmodule>\r\n f(lambda: print('hello'))\r\n File \"n.py\", line 5, in f\r\n 1 + 'boom'\r\nTypeError: unsupported operand type(s) for +: 'int' and 'str'\r\n```","author":{"url":"https://github.com/ilinum","@type":"Person","name":"ilinum"},"datePublished":"2017-06-23T22:59:36Z","url":"https://github.com/python/mypy/issues/3605"}
| 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:8307b0c4-3438-0cee-80a8-ca79ffa3ede5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8672:73851:55F7AC:7728E7:6B0019FE |
| html-safe-nonce | 1772f5b41a2d0424c67bcb99ab6d84a23aa69e627b70ce65c401ec71483e2bdd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjcyOjczODUxOjU1RjdBQzo3NzI4RTc6NkIwMDE5RkUiLCJ2aXNpdG9yX2lkIjoiNjUxOTU4MTIyMjYyNzE4NzE5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1d5fbac4944eac6ded028b6f8e9746bcbbb7297221d22439111015aa895c04a1 |
| hovercard-subject-tag | issue:238271729 |
| 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/3605/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b0cf9dea9be149a2c5d35c3104529118f93464bd622c401b493ed264f2e7f39/python/mypy/issues/3605 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b0cf9dea9be149a2c5d35c3104529118f93464bd622c401b493ed264f2e7f39/python/mypy/issues/3605 |
| og:image:alt | In the following code, mypy thinking callable(o) always returns False. This might be related to #3603. def f(o: object) -> None: if callable(o): # this branch is not typechecked o() 1 + 'boom' # no... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ilinum |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width