Title: Adding # type: ignore to EnumClass[string_value] doesn't set the type to Any · Issue #2416 · python/mypy · GitHub
Open Graph Title: Adding # type: ignore to EnumClass[string_value] doesn't set the type to Any · Issue #2416 · python/mypy
X Title: Adding # type: ignore to EnumClass[string_value] doesn't set the type to Any · Issue #2416 · python/mypy
Description: Example: from typing import Dict from enum import Enum class E(Enum): V = 'V' d = {} # type: Dict[E, int] def f(s: str): e = E[s] # type: ignore d[e] = 0 # Still error here We have to use # type: ignore on the line e = E[s] because of #7...
Open Graph Description: Example: from typing import Dict from enum import Enum class E(Enum): V = 'V' d = {} # type: Dict[E, int] def f(s: str): e = E[s] # type: ignore d[e] = 0 # Still error here We have to use # type: i...
X Description: Example: from typing import Dict from enum import Enum class E(Enum): V = 'V' d = {} # type: Dict[E, int] def f(s: str): e = E[s] # type: ignore d[e] = 0 # Still error here We have to use #...
Opengraph URL: https://github.com/python/mypy/issues/2416
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Adding # type: ignore to EnumClass[string_value] doesn't set the type to Any","articleBody":"Example:\r\n```python\r\nfrom typing import Dict\r\nfrom enum import Enum\r\nclass E(Enum):\r\n V = 'V'\r\nd = {} # type: Dict[E, int]\r\ndef f(s: str):\r\n e = E[s] # type: ignore\r\n d[e] = 0 # Still error here\r\n```\r\nWe have to use `# type: ignore` on the line `e = E[s]` because of #741. But somehow the type of `e`, when ignoring the error, is not `Any` but something else. So on the last line we get\r\n```\r\n__tmp__.py: note: In function \"f\":\r\n__tmp__.py:8: error: Invalid index type \"E\" for \"dict\"\r\n```\r\nThe weird thing is that if e had type E, d[e] would be valid, so the error is also somehow lying...\r\n\r\n**UPDATE:** When trying to repro this, don't try E['V'] -- mypy sees the literal and gives some other error, probably also because of #741.","author":{"url":"https://github.com/gvanrossum","@type":"Person","name":"gvanrossum"},"datePublished":"2016-11-07T22:32:26Z","url":"https://github.com/python/mypy/issues/2416"}
| 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:53c46219-88d9-915a-36d3-8be262c91572 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95B8:1BAA33:14181B7:1A7F342:6B000CCB |
| html-safe-nonce | 9d8d82de0d58899d390a82c916db3228319c4d791b2abdaa1a32e36151bb2609 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUI4OjFCQUEzMzoxNDE4MUI3OjFBN0YzNDI6NkIwMDBDQ0IiLCJ2aXNpdG9yX2lkIjoiNTk4NjcwOTMzMzIwMTY1MjkzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ce3619e7b57f50078560645e1d19242d7412e34e677c700a12eedb758117b2f9 |
| hovercard-subject-tag | issue:187848868 |
| 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/2416/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c94437b8bb0f2c268f6a1be54fe6ad30dbc4e15e521e9c6ccbe12b4c866c857e/python/mypy/issues/2416 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c94437b8bb0f2c268f6a1be54fe6ad30dbc4e15e521e9c6ccbe12b4c866c857e/python/mypy/issues/2416 |
| og:image:alt | Example: from typing import Dict from enum import Enum class E(Enum): V = 'V' d = {} # type: Dict[E, int] def f(s: str): e = E[s] # type: ignore d[e] = 0 # Still error here We have to use # type: i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gvanrossum |
| hostname | github.com |
| expected-hostname | github.com |
| None | cf7ee0062053ad9eb05b6e5de57bd96c2055708bcbada4144946b5ec129cf1d7 |
| 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 | 9cab7de176a56362d2aabcbb4d1e07e846eba8a0 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width