Title: Sum of an iterable of bools is considered to have a bool type · Issue #7579 · python/typeshed · GitHub
Open Graph Title: Sum of an iterable of bools is considered to have a bool type · Issue #7579 · python/typeshed
X Title: Sum of an iterable of bools is considered to have a bool type · Issue #7579 · python/typeshed
Description: Consider the following code foo = sum([True, False]) foo += 1 mypy v0.931 is OK with it and reports foo type as int mypy v0.940 warns Incompatible types in assignment (expression has type "int", variable has type "Union[bool, Literal[0]]...
Open Graph Description: Consider the following code foo = sum([True, False]) foo += 1 mypy v0.931 is OK with it and reports foo type as int mypy v0.940 warns Incompatible types in assignment (expression has type "int", va...
X Description: Consider the following code foo = sum([True, False]) foo += 1 mypy v0.931 is OK with it and reports foo type as int mypy v0.940 warns Incompatible types in assignment (expression has type "int...
Opengraph URL: https://github.com/python/typeshed/issues/7579
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sum of an iterable of bools is considered to have a bool type","articleBody":"Consider the following code\r\n\r\n```python\r\nfoo = sum([True, False])\r\nfoo += 1\r\n```\r\n\r\n- `mypy` v0.931 is OK with it and reports `foo` type as `int`\r\n- `mypy` v0.940 warns\r\n\r\n```\r\nIncompatible types in assignment (expression has type \"int\", variable has type \"Union[bool, Literal[0]]\")\r\n```\r\n\r\nThe stub [does indeed state][line]\r\n\r\n```python\r\n@overload\r\ndef sum(__iterable: Iterable[_SumT]) -> _SumT | Literal[0]: ...\r\n```\r\n\r\nThough it is somewhat unfortunate. I've [got beaten][ci] by this after updating `mypy` to the latest version.\r\n\r\n[ci]: https://github.com/lancelote/leetcode/runs/5795064713?check_suite_focus=true\r\n[line]: https://github.com/python/typeshed/blob/d45c9084a4886bc477ee171e4ef8ed3117291f32/stdlib/builtins.pyi#L1488","author":{"url":"https://github.com/lancelote","@type":"Person","name":"lancelote"},"datePublished":"2022-04-02T18:58:31Z","url":"https://github.com/python/typeshed/issues/7579"}
| 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:afbdaf5f-35f3-2e20-5fa0-20b14d7c4c5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 90E4:07D0:210DF16:2BCCA10:6B0050F3 |
| html-safe-nonce | c14c110aa2dfcae4556f1f5b6313afc9d2ee0f6a489b2a22a291ae0f26172813 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEU0OjA3RDA6MjEwREYxNjoyQkNDQTEwOjZCMDA1MEYzIiwidmlzaXRvcl9pZCI6IjM5OTYxOTQ4Mjg5MDI5MzQ5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b5e6010f8792c968543f3069e01be8bacb0c37bc3e6216712a042d34cf42828c |
| hovercard-subject-tag | issue:1190713423 |
| 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/typeshed/7579/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3de18c3907c6de9e7ecea29dc42d6d816ad1111c4ac89fcbd8dc927283e977cd/python/typeshed/issues/7579 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3de18c3907c6de9e7ecea29dc42d6d816ad1111c4ac89fcbd8dc927283e977cd/python/typeshed/issues/7579 |
| og:image:alt | Consider the following code foo = sum([True, False]) foo += 1 mypy v0.931 is OK with it and reports foo type as int mypy v0.940 warns Incompatible types in assignment (expression has type "int", va... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lancelote |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width