Title: Use type context from previous definition when renaming · Issue #6231 · python/mypy · GitHub
Open Graph Title: Use type context from previous definition when renaming · Issue #6231 · python/mypy
X Title: Use type context from previous definition when renaming · Issue #6231 · python/mypy
Description: Maybe we code like this shouldn't generate an error when using --allow-redefinition: x: List[int] = [] # do something with x x = [] # Error: need annotation The reason for the error is that the second assignment creates a completely inde...
Open Graph Description: Maybe we code like this shouldn't generate an error when using --allow-redefinition: x: List[int] = [] # do something with x x = [] # Error: need annotation The reason for the error is that the sec...
X Description: Maybe we code like this shouldn't generate an error when using --allow-redefinition: x: List[int] = [] # do something with x x = [] # Error: need annotation The reason for the error is that the...
Opengraph URL: https://github.com/python/mypy/issues/6231
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use type context from previous definition when renaming","articleBody":"Maybe we code like this shouldn't generate an error when using `--allow-redefinition`:\r\n\r\n```py\r\nx: List[int] = []\r\n# do something with x\r\nx = [] # Error: need annotation\r\n```\r\n\r\nThe reason for the error is that the second assignment creates a completely independent variable, so the type of the original definition has no effect.\r\n\r\nThere are still some open issues:\r\n* Using the context can generate false positives, in case the correct type would be something different for the second definition. I don't know how often this would be an issue.\r\n* Propagating the type context is somewhat tricky since the name of the previous definition is not trivial to calculate. The rules for renaming depend on the scope (local/class/global).\r\n* If/when we support more general redefinitions (not just within a single block), it may be unclear when we should propagate context. It may be best to first to make redefinitions more general and then reconsider this issue.\r\n\r\nFollow-up to #6197.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2019-01-21T12:18:58Z","url":"https://github.com/python/mypy/issues/6231"}
| 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:6928e656-094a-be4f-fe72-3a72ffcce736 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9062:108997:527F64:70A7DE:6B00732E |
| html-safe-nonce | 14fa459da8ecb334e91c1d8776c731bdbba9f6a0c2eb2315df02e8fcf469c3c8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDYyOjEwODk5Nzo1MjdGNjQ6NzBBN0RFOjZCMDA3MzJFIiwidmlzaXRvcl9pZCI6IjE5Nzc5NDY2NzkxNDMzMzA2MDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b7050198075d3736f8c855dd9c99d8bec5299aa1882afe74977c458603232881 |
| hovercard-subject-tag | issue:401328299 |
| 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/6231/issue_layout |
| twitter:image | https://opengraph.githubassets.com/54ba53457979d2cfca335168add5d11fb951fe68b4b6bc065ccb75ca404e0291/python/mypy/issues/6231 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/54ba53457979d2cfca335168add5d11fb951fe68b4b6bc065ccb75ca404e0291/python/mypy/issues/6231 |
| og:image:alt | Maybe we code like this shouldn't generate an error when using --allow-redefinition: x: List[int] = [] # do something with x x = [] # Error: need annotation The reason for the error is that the sec... |
| 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 | 75c2b65dd205f26961d0c29afed1a8d0bb7cca9f05780571dfd1ef93eb539d16 |
| 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 | 84e563eb4b55f8fa102f325f117533cee9e3df4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width