Title: Cannot use Literal variable inside Literal type · Issue #8187 · python/mypy · GitHub
Open Graph Title: Cannot use Literal variable inside Literal type · Issue #8187 · python/mypy
X Title: Cannot use Literal variable inside Literal type · Issue #8187 · python/mypy
Description: Using mypy 0.761, Python 3.7.5 here. The ANIMALS2 value is highlighted as incorrect by Mypy: COW: Literal['cow'] = 'cow' PIG: Literal['pig'] = 'pig' ANIMALS1: Literal['cow', 'pig'] # This is OK ANIMALS2: Literal[COW, PIG] # ^^^^^^^ Mypy:...
Open Graph Description: Using mypy 0.761, Python 3.7.5 here. The ANIMALS2 value is highlighted as incorrect by Mypy: COW: Literal['cow'] = 'cow' PIG: Literal['pig'] = 'pig' ANIMALS1: Literal['cow', 'pig'] # This is OK ANI...
X Description: Using mypy 0.761, Python 3.7.5 here. The ANIMALS2 value is highlighted as incorrect by Mypy: COW: Literal['cow'] = 'cow' PIG: Literal['pig'] = 'pig' ANIMALS1: Litera...
Opengraph URL: https://github.com/python/mypy/issues/8187
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot use Literal variable inside Literal type","articleBody":"Using mypy 0.761, Python 3.7.5 here. The `ANIMALS2` value is highlighted as incorrect by Mypy:\r\n```python\r\nCOW: Literal['cow'] = 'cow'\r\nPIG: Literal['pig'] = 'pig'\r\nANIMALS1: Literal['cow', 'pig'] # This is OK\r\nANIMALS2: Literal[COW, PIG]\r\n# ^^^^^^^ Mypy: Parameter 1 of Literal[...] is invalid\r\n```\r\n\r\nBut it seems Mypy should be able to deduce that ANIMALS1 and ANIMALS2 are the same thing?\r\n\r\nI'm not sure if the more lax version should be allowed as well, but seems useful:\r\n\r\n```python\r\nOX = 'ox'\r\nANIMALS = Literal[OX]\r\n```\r\n","author":{"url":"https://github.com/intgr","@type":"Person","name":"intgr"},"datePublished":"2019-12-20T12:32:00Z","url":"https://github.com/python/mypy/issues/8187"}
| 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:ee816304-c279-75f6-74bc-07d2db81439f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D42:100874:116790F:16DCAC6:6B000AA0 |
| html-safe-nonce | 0c3fcd7f51a16b3199620e77bb8bca357ae3628e6b38d3395ce3c7b0e1fc33e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDQyOjEwMDg3NDoxMTY3OTBGOjE2RENBQzY6NkIwMDBBQTAiLCJ2aXNpdG9yX2lkIjoiMzg3NTIwMjA4NzkxNDU3MjQ0OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 83a9e206b683f6a2424a5e19332f5b58f2d0bd09513a1dadb9c89807aa82924b |
| hovercard-subject-tag | issue:540972854 |
| 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/8187/issue_layout |
| twitter:image | https://opengraph.githubassets.com/283924e886aed7e7a0a7b5d6b7314fb6e484c5ea82bc2a52181892a2f8646fe8/python/mypy/issues/8187 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/283924e886aed7e7a0a7b5d6b7314fb6e484c5ea82bc2a52181892a2f8646fe8/python/mypy/issues/8187 |
| og:image:alt | Using mypy 0.761, Python 3.7.5 here. The ANIMALS2 value is highlighted as incorrect by Mypy: COW: Literal['cow'] = 'cow' PIG: Literal['pig'] = 'pig' ANIMALS1: Literal['cow', 'pig'] # This is OK ANI... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | intgr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width