Title: Protocols and `... if ... else ...` · Issue #5392 · python/mypy · GitHub
Open Graph Title: Protocols and `... if ... else ...` · Issue #5392 · python/mypy
X Title: Protocols and `... if ... else ...` · Issue #5392 · python/mypy
Description: python/typeshed#2323 exposed a problem with mypy's (lack of) handling of protocols in ... if ... else ... constructs. Please consider: from typing import SupportsFloat class Floaty: def __float__(self): ... class Supporter(SupportsFloat)...
Open Graph Description: python/typeshed#2323 exposed a problem with mypy's (lack of) handling of protocols in ... if ... else ... constructs. Please consider: from typing import SupportsFloat class Floaty: def __float__(s...
X Description: python/typeshed#2323 exposed a problem with mypy's (lack of) handling of protocols in ... if ... else ... constructs. Please consider: from typing import SupportsFloat class Floaty: def __float...
Opengraph URL: https://github.com/python/mypy/issues/5392
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Protocols and `... if ... else ...`","articleBody":"python/typeshed#2323 exposed a problem with mypy's (lack of) handling of protocols in `... if ... else ...` constructs. Please consider:\r\n\r\n```\r\nfrom typing import SupportsFloat\r\n\r\nclass Floaty:\r\n def __float__(self): ...\r\n\r\nclass Supporter(SupportsFloat):\r\n def __float__(self): ...\r\n\r\nreveal_type(Floaty() if bool() else 0)\r\nreveal_type(Supporter() if bool() else 0)\r\n```\r\n\r\nThis will reveal the type of the first expression to be `builtins.object`, while the latter is `typing.SupportsFloat`. This means that mypy (tested with 0.620, Python 3.7.0) will reject, for example `float(Floaty() if bool() else 0)`.","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2018-07-26T08:37:51Z","url":"https://github.com/python/mypy/issues/5392"}
| 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:3491608a-a105-f7e8-3852-85fa2386cca1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CAF6:1DA29F:14A6A01:1B1D56F:6B000C87 |
| html-safe-nonce | 743e5073e7544e181de9482336855d380634ae5c73a208e3a96334c461f2785b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUY2OjFEQTI5RjoxNEE2QTAxOjFCMUQ1NkY6NkIwMDBDODciLCJ2aXNpdG9yX2lkIjoiMzUyODk3MjAyNjcyMTA3ODQwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d24218aeb83893fe7b2328a69a2e4c6c9d55a4a01fbf262e3ed26178371d6e2a |
| hovercard-subject-tag | issue:344747606 |
| 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/5392/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e7b7d2ceb446befc78c6adb83d2f653f8a2e71001be74b6b3e6f71a2a1084af8/python/mypy/issues/5392 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e7b7d2ceb446befc78c6adb83d2f653f8a2e71001be74b6b3e6f71a2a1084af8/python/mypy/issues/5392 |
| og:image:alt | python/typeshed#2323 exposed a problem with mypy's (lack of) handling of protocols in ... if ... else ... constructs. Please consider: from typing import SupportsFloat class Floaty: def __float__(s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| 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