Title: Apparent false positive when using reduce with dictionaries · Issue #4150 · python/mypy · GitHub
Open Graph Title: Apparent false positive when using reduce with dictionaries · Issue #4150 · python/mypy
X Title: Apparent false positive when using reduce with dictionaries · Issue #4150 · python/mypy
Description: Python 3.6.3, mypy 0.521. When using reduce on an Iterable/List of dictionaries, mypy seems to be confused about the signature of the function and seems to be unpacking the dictionary into an iterable of tuples. The following example app...
Open Graph Description: Python 3.6.3, mypy 0.521. When using reduce on an Iterable/List of dictionaries, mypy seems to be confused about the signature of the function and seems to be unpacking the dictionary into an itera...
X Description: Python 3.6.3, mypy 0.521. When using reduce on an Iterable/List of dictionaries, mypy seems to be confused about the signature of the function and seems to be unpacking the dictionary into an itera...
Opengraph URL: https://github.com/python/mypy/issues/4150
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Apparent false positive when using reduce with dictionaries","articleBody":"Python 3.6.3, mypy 0.521.\r\n\r\nWhen using `reduce` on an Iterable/List of dictionaries, mypy seems to be confused about the signature of the function and seems to be unpacking the dictionary into an iterable of tuples. The following example appears to conform to the reduce function's parameters, so no errors should be appearing.\r\n\r\nhttps://docs.python.org/3.6/library/functools.html#functools.reduce\r\n\r\n```\r\ntest.py:14: error: Argument 1 to \"reduce\" has incompatible type Callable[[Dict[Any, Any], Dict[Any, Any]], Dict[Any, Any]]; expected Callable[[Iterable[Tuple[Any, Any]], Dict[Any, Any]], Iterable[Tuple[Any, Any]]]\r\n```\r\n\r\n```python\r\n#!/usr/bin/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\nfrom functools import reduce\r\n\r\nfrom typing import Iterable\r\n\r\ndef update(ccc: dict, meta: dict) -> dict:\r\n foo = dict(ccc)\r\n foo.update(meta)\r\n return foo\r\n\r\ndef reduce_func(configs: Iterable[dict]) -> dict:\r\n output = dict(reduce(update, configs, {})) # type: dict\r\n return output\r\n\r\nprint(reduce_func([{\"a\": 1}, {\"b\": 2}]))\r\n\r\n```","author":{"url":"https://github.com/edwardcwang","@type":"Person","name":"edwardcwang"},"datePublished":"2017-10-23T05:50:31Z","url":"https://github.com/python/mypy/issues/4150"}
| 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:7b12a61c-ccbb-bce8-05d2-38f5025df5b1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D066:DD1C:1B546E6:24DFFA7:6B0003D0 |
| html-safe-nonce | 880d4e4c839eca2e82bb4dab2eebe6da78639b5d8cd8ef93624a90825b08b6dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDY2OkREMUM6MUI1NDZFNjoyNERGRkE3OjZCMDAwM0QwIiwidmlzaXRvcl9pZCI6IjU3MTczNDQxMzcwNDExNTA5MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | dbd746b2fcd58798083aabd11172995d16a661c6920e7f4d27a10172e95ad48d |
| hovercard-subject-tag | issue:267548291 |
| 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/4150/issue_layout |
| twitter:image | https://opengraph.githubassets.com/05ebd25b3a513339b9b8700792e19bcdbc2ef16eb9a930c80545c9195af15b0a/python/mypy/issues/4150 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/05ebd25b3a513339b9b8700792e19bcdbc2ef16eb9a930c80545c9195af15b0a/python/mypy/issues/4150 |
| og:image:alt | Python 3.6.3, mypy 0.521. When using reduce on an Iterable/List of dictionaries, mypy seems to be confused about the signature of the function and seems to be unpacking the dictionary into an itera... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edwardcwang |
| 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