Title: Binder fails to track loops correctly · Issue #18348 · python/mypy · GitHub
Open Graph Title: Binder fails to track loops correctly · Issue #18348 · python/mypy
X Title: Binder fails to track loops correctly · Issue #18348 · python/mypy
Description: # mypy: enable-error-code=redundant-expr from __future__ import annotations class Node: parent: Node | None is_valid: bool def traverse_needs_fixing(self) -> Node | None: it: Node | None it = self while it is not None and it.is_valid: # ...
Open Graph Description: # mypy: enable-error-code=redundant-expr from __future__ import annotations class Node: parent: Node | None is_valid: bool def traverse_needs_fixing(self) -> Node | None: it: Node | None it = self ...
X Description: # mypy: enable-error-code=redundant-expr from __future__ import annotations class Node: parent: Node | None is_valid: bool def traverse_needs_fixing(self) -> Node | None: it: Node | None it = se...
Opengraph URL: https://github.com/python/mypy/issues/18348
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Binder fails to track loops correctly","articleBody":"```python\r\n# mypy: enable-error-code=redundant-expr\r\nfrom __future__ import annotations\r\n\r\nclass Node:\r\n parent: Node | None\r\n is_valid: bool\r\n\r\n def traverse_needs_fixing(self) -\u003e Node | None:\r\n it: Node | None\r\n it = self\r\n while it is not None and it.is_valid: # E: Left operand of \"and\" is always true [redundant-expr]\r\n it = it.parent\r\n return it\r\n\r\n def traverse(self) -\u003e Node | None:\r\n # this only works because mypy does not narrow on initial assignment\r\n # which is something we'd like to change, see #2008\r\n it: Node | None = self\r\n while it is not None and it.is_valid:\r\n it = it.parent\r\n return it\r\n```","author":{"url":"https://github.com/hauntsaninja","@type":"Person","name":"hauntsaninja"},"datePublished":"2024-12-28T02:37:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/18348/mypy/issues/18348"}
| 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:99d3cf90-a804-22ff-7912-eff45e7e5810 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD2E:3EE21F:5401272:6E6B2B1:6A5D990D |
| html-safe-nonce | 2d46c5002ddd03759b6cec00a278173db3c8cffb35e336344c3c49626d19452e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDJFOjNFRTIxRjo1NDAxMjcyOjZFNkIyQjE6NkE1RDk5MEQiLCJ2aXNpdG9yX2lkIjoiMTcwNDEzNDUwNzA3NDQxOTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 05c8bac46ddfc2ed68b2bc6f5cfd8e576ab04f72c3f8ee4fcb44d6521d833080 |
| hovercard-subject-tag | issue:2761403053 |
| 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/18348/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d78cde0e42ee059106567199669274c28e49f2c74080bc48531625274b5a0d1/python/mypy/issues/18348 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d78cde0e42ee059106567199669274c28e49f2c74080bc48531625274b5a0d1/python/mypy/issues/18348 |
| og:image:alt | # mypy: enable-error-code=redundant-expr from __future__ import annotations class Node: parent: Node | None is_valid: bool def traverse_needs_fixing(self) -> Node | None: it: Node | None it = self ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hauntsaninja |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width