Title: Recognize `callable` in conditional type binding · Issue #1973 · python/mypy · GitHub
Open Graph Title: Recognize `callable` in conditional type binding · Issue #1973 · python/mypy
X Title: Recognize `callable` in conditional type binding · Issue #1973 · python/mypy
Description: If I run mypy against the following code: from typing import Callable, Union SomeFieldType = Union[str, Callable[[str], int]] class SomeClass(object): def __init__(self, some_field: SomeFieldType) -> None: self.some_field = some_field de...
Open Graph Description: If I run mypy against the following code: from typing import Callable, Union SomeFieldType = Union[str, Callable[[str], int]] class SomeClass(object): def __init__(self, some_field: SomeFieldType) ...
X Description: If I run mypy against the following code: from typing import Callable, Union SomeFieldType = Union[str, Callable[[str], int]] class SomeClass(object): def __init__(self, some_field: SomeFieldType) ...
Opengraph URL: https://github.com/python/mypy/issues/1973
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Recognize `callable` in conditional type binding","articleBody":"If I run mypy against the following code:\n\n``` python\nfrom typing import Callable, Union\n\nSomeFieldType = Union[str, Callable[[str], int]]\n\nclass SomeClass(object):\n def __init__(self, some_field: SomeFieldType) -> None:\n self.some_field = some_field\n\n def do_something(self) -> None:\n if callable(self.some_field):\n self.some_field('foobar')\n```\n\nit complains about self.some_field not being callable:\n\n```\ntest_mypy.py: note: In member \"do_something\" of class \"SomeClass\":\ntest_mypy.py:11: error: \"str\" not callable\n```\n\nPerhaps mypy could be made aware of the \"callable(...)\" statements? Thanks!\n","author":{"url":"https://github.com/abarto-machinalis","@type":"Person","name":"abarto-machinalis"},"datePublished":"2016-08-01T19:16:20Z","url":"https://github.com/python/mypy/issues/1973"}
| 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:69487ed6-0811-eaae-f254-73f6512a9f77 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3D2:3FDF0C:9EE45:D4EE0:6B001BC3 |
| html-safe-nonce | d2240ee526ff926cb8cd38f7f8e458c1f874f03ab0f2def2f2c3df218e6843be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0QyOjNGREYwQzo5RUU0NTpENEVFMDo2QjAwMUJDMyIsInZpc2l0b3JfaWQiOiI1Mzg0ODAxMjA4OTA3MDc4NTk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b7eb55c9217612262760092206b1855b832504fd17104cb871634d27a2bc927f |
| hovercard-subject-tag | issue:168720174 |
| 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/1973/issue_layout |
| twitter:image | https://opengraph.githubassets.com/831af8981ccf64b40485d8e69607311dc1c01df452afbbc16f4c0a5168a37d7b/python/mypy/issues/1973 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/831af8981ccf64b40485d8e69607311dc1c01df452afbbc16f4c0a5168a37d7b/python/mypy/issues/1973 |
| og:image:alt | If I run mypy against the following code: from typing import Callable, Union SomeFieldType = Union[str, Callable[[str], int]] class SomeClass(object): def __init__(self, some_field: SomeFieldType) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abarto-machinalis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width