Title: Incorrect redundant cast warning in lambda · Issue #9568 · python/mypy · GitHub
Open Graph Title: Incorrect redundant cast warning in lambda · Issue #9568 · python/mypy
X Title: Incorrect redundant cast warning in lambda · Issue #9568 · python/mypy
Description: With a cast() in a lambda, --warn-redundant-cast tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790. $ cat tmp/matchcast.py from typing import cast, Match, Pattern def _get_no...
Open Graph Description: With a cast() in a lambda, --warn-redundant-cast tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790. $ cat tmp/matchcast.py from typing...
X Description: With a cast() in a lambda, --warn-redundant-cast tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790. $ cat tmp/matchcast.py from typing...
Opengraph URL: https://github.com/python/mypy/issues/9568
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect redundant cast warning in lambda","articleBody":"With a `cast()` in a lambda, `--warn-redundant-cast` tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790.\r\n\r\n```\r\n$ cat tmp/matchcast.py \r\nfrom typing import cast, Match, Pattern\r\n\r\n\r\ndef _get_nodes(key: str, rgx: Pattern[str]) -\u003e None:\r\n matches = rgx.fullmatch(key)\r\n if matches is None:\r\n return\r\n\r\n sorted(\r\n matches.groupdict().items(),\r\n key=lambda g: cast(Match[str], matches).start(g[0]),\r\n )\r\n$ mypy --warn-redundant-casts tmp/matchcast.py \r\ntmp/matchcast.py:11: error: Redundant cast to \"Match[str]\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\nAnd if I remove the cast:\r\n```\r\n$ mypy --warn-redundant-casts tmp/matchcast.py \r\ntmp/matchcast.py:11: error: Item \"None\" of \"Optional[Match[str]]\" has no attribute \"start\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.790\r\n- Mypy command-line flags: `--warn-redundant-casts`\r\n- Python version used: 3.6\r\n- Operating system and version: Ubuntu\r\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2020-10-09T18:43:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/9568/mypy/issues/9568"}
| 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:bdb013d5-b1d4-fafa-5dd9-7d6f38246ed4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A610:10C018:18BBF4:219559:6A612FDC |
| html-safe-nonce | ebb6742a96eb32bb0d3a40f11394069dbdfb4782099f870145be8828c550e8e4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjEwOjEwQzAxODoxOEJCRjQ6MjE5NTU5OjZBNjEyRkRDIiwidmlzaXRvcl9pZCI6IjQzMDc3MDU2MzM5MTM3NzgxNDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e1f378baf72326a242b48c92fa7710a30629a82cf459e410e85fdc90abb66330 |
| hovercard-subject-tag | issue:718351163 |
| 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/9568/issue_layout |
| twitter:image | https://opengraph.githubassets.com/157a04d47bebbf57b6efa81ce8f743efcf4705a1a48f5db262d6eb2fb686639d/python/mypy/issues/9568 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/157a04d47bebbf57b6efa81ce8f743efcf4705a1a48f5db262d6eb2fb686639d/python/mypy/issues/9568 |
| og:image:alt | With a cast() in a lambda, --warn-redundant-cast tells me to remove the cast, but then I get a different error if I actually do so. This is a regression in 0.790. $ cat tmp/matchcast.py from typing... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | c5eca2d5d770261725d2d44a57879a5bd9643e5b84204081dc36933ab40e63a2 |
| 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 | dac3a1c903b48538720e0bc780047237dd89fd4c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width