Title: Generate better error message for incompatible **kwargs · Issue #8874 · python/mypy · GitHub
Open Graph Title: Generate better error message for incompatible **kwargs · Issue #8874 · python/mypy
X Title: Generate better error message for incompatible **kwargs · Issue #8874 · python/mypy
Description: This output is from #8772: $ mypy test.py test.py:6: error: Argument 2 to "dumps" has incompatible type "**Dict[str, int]"; expected "bool" test.py:6: error: Argument 2 to "dumps" has incompatible type "**Dict[str, int]"; expected "Optio...
Open Graph Description: This output is from #8772: $ mypy test.py test.py:6: error: Argument 2 to "dumps" has incompatible type "**Dict[str, int]"; expected "bool" test.py:6: error: Argument 2 to "dumps" has incompatible ...
X Description: This output is from #8772: $ mypy test.py test.py:6: error: Argument 2 to "dumps" has incompatible type "**Dict[str, int]"; expected "bool" test.py:6: error: Argument ...
Opengraph URL: https://github.com/python/mypy/issues/8874
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generate better error message for incompatible **kwargs","articleBody":"This output is from #8772:\r\n\r\n```\r\n$ mypy test.py \r\ntest.py:6: error: Argument 2 to \"dumps\" has incompatible type \"**Dict[str, int]\"; expected \"bool\"\r\ntest.py:6: error: Argument 2 to \"dumps\" has incompatible type \"**Dict[str, int]\"; expected \"Optional[Type[JSONEncoder]]\"\r\ntest.py:6: error: Argument 2 to \"dumps\" has incompatible type \"**Dict[str, int]\"; expected \"Optional[Tuple[str, str]]\"\r\ntest.py:6: error: Argument 2 to \"dumps\" has incompatible type \"**Dict[str, int]\"; expected \"Optional[Callable[[Any], Any]]\"\r\nFound 4 errors in 1 file (checked 1 source file)\r\n```\r\n\r\nThe error messages are pretty confusing. We should special case this and produce a customized error message that explains the situation better.\r\n\r\nHere's the code that triggers the errors:\r\n\r\n```py\r\nimport json\r\n\r\njson_kwargs = dict(indent=2)\r\n\r\njson.dumps({}, **json_kwargs)\r\n```\r\n\r\nSome ideas about what to do:\r\n* Generate a single error message instead of multiple ones.\r\n* Add a note suggesting the use of `Dict[str, Any]` or a TypedDict type for the `**kwargs` argument.\r\n* Maybe also explain that mypy matches the value type against all arguments, or add a link to documentation (add something to common issues, for example).\r\n","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2020-05-22T14:16:44Z","url":"https://github.com/python/mypy/issues/8874"}
| 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:b4dbf0e7-406a-d4e6-565d-122fd6e909d6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 87B4:156D4E:10DAF41:1605A43:6AFFFB74 |
| html-safe-nonce | 26247402864c071503e52cf946959f32f8527bfb69a78783bfb52da93bf97bba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4N0I0OjE1NkQ0RToxMERBRjQxOjE2MDVBNDM6NkFGRkZCNzQiLCJ2aXNpdG9yX2lkIjoiMzUyMDg4NDg4MjQ3NTU4MDI3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4d890abfdd4023ccd28146ab53b9e893c8376ce05ad88ae579396929bfc61e4a |
| hovercard-subject-tag | issue:623241525 |
| 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/8874/issue_layout |
| twitter:image | https://opengraph.githubassets.com/51371ac4ea2b73ec01a05e2fed74e5546043869b3183b14c4e254c9913a1a7f1/python/mypy/issues/8874 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/51371ac4ea2b73ec01a05e2fed74e5546043869b3183b14c4e254c9913a1a7f1/python/mypy/issues/8874 |
| og:image:alt | This output is from #8772: $ mypy test.py test.py:6: error: Argument 2 to "dumps" has incompatible type "**Dict[str, int]"; expected "bool" test.py:6: error: Argument 2 to "dumps" has incompatible ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| 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