Title: Processing of Callables in make_simplified_union is order dependent · Issue #2031 · python/mypy · GitHub
Open Graph Title: Processing of Callables in make_simplified_union is order dependent · Issue #2031 · python/mypy
X Title: Processing of Callables in make_simplified_union is order dependent · Issue #2031 · python/mypy
Description: from typing import Union, Any class A(): def foo(self, x: Any) -> None: pass class B(): def foo(self, x: str) -> None: pass def f(c: Union[A, B]) -> None: reveal_type(c.foo) # E: Revealed type is 'def (x: Any)' def g(c: Union[B, A]) -> N...
Open Graph Description: from typing import Union, Any class A(): def foo(self, x: Any) -> None: pass class B(): def foo(self, x: str) -> None: pass def f(c: Union[A, B]) -> None: reveal_type(c.foo) # E: Revealed type is '...
X Description: from typing import Union, Any class A(): def foo(self, x: Any) -> None: pass class B(): def foo(self, x: str) -> None: pass def f(c: Union[A, B]) -> None: reveal_type(c.foo) # E: Revealed ...
Opengraph URL: https://github.com/python/mypy/issues/2031
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Processing of Callables in make_simplified_union is order dependent","articleBody":"``` py\nfrom typing import Union, Any\n\nclass A():\n def foo(self, x: Any) -> None: pass\n\nclass B():\n def foo(self, x: str) -> None: pass\n\ndef f(c: Union[A, B]) -> None:\n reveal_type(c.foo) # E: Revealed type is 'def (x: Any)'\n\ndef g(c: Union[B, A]) -> None:\n reveal_type(c.foo) # E: Revealed type is 'def (x: builtins.str)'\n```\n\nPrior to #1989 the order of processing was reversed, which is how this bug was discovered. I think what's going on is that `Callable[[Any], None]` is compatible with `Callable[[str], None]` and vice-versa, so our \"`is_subtype`\" check is combining them.\n\nOne possible resolution is to only combine identical types in `make_simplified_union`, not \"subtypes\".\n","author":{"url":"https://github.com/ddfisher","@type":"Person","name":"ddfisher"},"datePublished":"2016-08-17T00:28:51Z","url":"https://github.com/python/mypy/issues/2031"}
| 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:e681e8f3-4882-825c-1787-1c0d952e72c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 904C:27E6DD:141BA80:1A66A15:6B000AE8 |
| html-safe-nonce | 4eb0c17bd2de4a3b0c65df63d37c040a1f826edefc0e566b53cfa73bd6c60693 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDRDOjI3RTZERDoxNDFCQTgwOjFBNjZBMTU6NkIwMDBBRTgiLCJ2aXNpdG9yX2lkIjoiNzkyMTg1ODYxNTY1NTI3MTE0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 36ecf4a2308f5a8c182c94e342a45c902fe74b8a590531188064fb7ea3cf9613 |
| hovercard-subject-tag | issue:171548775 |
| 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/2031/issue_layout |
| twitter:image | https://opengraph.githubassets.com/50300e48ee0fd443c540af85338492fda370137fdd90a4fbc3e4fb6e52043216/python/mypy/issues/2031 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/50300e48ee0fd443c540af85338492fda370137fdd90a4fbc3e4fb6e52043216/python/mypy/issues/2031 |
| og:image:alt | from typing import Union, Any class A(): def foo(self, x: Any) -> None: pass class B(): def foo(self, x: str) -> None: pass def f(c: Union[A, B]) -> None: reveal_type(c.foo) # E: Revealed type is '... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ddfisher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width