Title: Optional strict checking of *args and/or multiple assignment · Issue #7408 · python/mypy · GitHub
Open Graph Title: Optional strict checking of *args and/or multiple assignment · Issue #7408 · python/mypy
X Title: Optional strict checking of *args and/or multiple assignment · Issue #7408 · python/mypy
Description: Currently mypy does optimistic checking of *args -- we don't generate error if it could be valid. This seems like a reasonable default, since it avoids false positive errors. However, some users might prefer stricter checking as an optio...
Open Graph Description: Currently mypy does optimistic checking of *args -- we don't generate error if it could be valid. This seems like a reasonable default, since it avoids false positive errors. However, some users mi...
X Description: Currently mypy does optimistic checking of *args -- we don't generate error if it could be valid. This seems like a reasonable default, since it avoids false positive errors. However, some user...
Opengraph URL: https://github.com/python/mypy/issues/7408
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Optional strict checking of *args and/or multiple assignment","articleBody":"Currently mypy does optimistic checking of `*args` -- we don't generate error if it could be valid. This seems like a reasonable default, since it avoids false positive errors. However, some users might prefer stricter checking as an option. When this option is enabled, mypy would only allow variable-length (non-`Any`) `*args` in a call if the callee also accepts `*args`.\r\n\r\nExample:\r\n\r\n```py\r\ndef f(a: int) -> None: pass\r\n\r\nx = [1, 2]\r\nf(*x) # Currently accepted, since mypy doesn't know the length of x\r\n```\r\n\r\nPR #7392 relaxed the rules so that we assume that any list `*args` argument could be empty and thus we don't complain about even if a caller `*args` argument is only valid when it's empty.\r\n\r\nSimilarly this option (or a similar option) could reject variable-length rvalues in multiple assignment like this:\r\n\r\n```py\r\nx = [1, 2]\r\na, b, c = x # Currently accepted\r\n```\r\n\r\nIf we'd have support for enabling/disabling specific error codes, these checks could easily be implemented through error codes that are disabled by default.\r\n\r\nRefactoring code such as the above (if correct) to pass mypy could be somewhat painful, however. It could be written like this:\r\n\r\n```py\r\ndef f(a: int, b: int) -> None: pass\r\n\r\ndef g(x: List[int]) -> None:\r\n assert len(x) == 2\r\n f(x[0], x[1])\r\n```\r\n\r\n(Of course, a `# type: ignore` would also work.)","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2019-08-29T13:29:44Z","url":"https://github.com/python/mypy/issues/7408"}
| 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:3c76c964-cc09-86cb-1af7-839e2e446549 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9BD8:3430F7:ADB207:E8C61E:6B0048A2 |
| html-safe-nonce | 555a00f1e39d81dfd78a82645165d993aaae211019995bf1f7eafc25f038e552 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkQ4OjM0MzBGNzpBREIyMDc6RThDNjFFOjZCMDA0OEEyIiwidmlzaXRvcl9pZCI6Ijk5Mjc1NTQxNTY1NTY2Mzc3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f97ec0cee521f0aee22e81482bb5b6d1591780b41b495eac6d5495b251937b2 |
| hovercard-subject-tag | issue:486959599 |
| 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/7408/issue_layout |
| twitter:image | https://opengraph.githubassets.com/536d2c717ffe567fb118d2fc7a071587b2ea6cf8fd5104691f7e7265ef02e83a/python/mypy/issues/7408 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/536d2c717ffe567fb118d2fc7a071587b2ea6cf8fd5104691f7e7265ef02e83a/python/mypy/issues/7408 |
| og:image:alt | Currently mypy does optimistic checking of *args -- we don't generate error if it could be valid. This seems like a reasonable default, since it avoids false positive errors. However, some users mi... |
| 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 | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width