Title: Redefining Literal class variable in subclass has 'Incompatible type' · Issue #8796 · python/mypy · GitHub
Open Graph Title: Redefining Literal class variable in subclass has 'Incompatible type' · Issue #8796 · python/mypy
X Title: Redefining Literal class variable in subclass has 'Incompatible type' · Issue #8796 · python/mypy
Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to simplify your case to a minimal repro. fro...
Open Graph Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
X Description: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si...
Opengraph URL: https://github.com/python/mypy/issues/8796
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Redefining Literal class variable in subclass has 'Incompatible type'","articleBody":"### Are you reporting a bug, or opening a feature request?\r\nBug\r\n### Please insert below the code you are checking with mypy,\r\n or a mock-up repro if the source is private. We would appreciate\r\n if you try to simplify your case to a minimal repro.\r\n```python\r\nfrom typing import Literal\r\n\r\nclass A:\r\n foo : Literal['bar', 'spam']= 'bar'\r\n \r\nclass B(A):\r\n foo = 'spam'\r\n```\r\n### What is the actual behavior/output?\r\n```\r\nmain.py:7: error: Incompatible types in assignment (expression has type \"str\", base class \"A\" defined the type as \"Union[Literal['bar'], Literal['spam']]\")\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n### What is the behavior/output you expect?\r\nI expected no error, as `B.foo` is still of type `Literal['bar', 'spam']`\r\n### What are the versions of mypy and Python you are using?\r\nmypy == 0.770\r\nPython == 3.8\r\n### What are the mypy flags you are using? (For example --strict-optional)\r\nno flags\r\n","author":{"url":"https://github.com/AugPro","@type":"Person","name":"AugPro"},"datePublished":"2020-05-11T12:22:41Z","url":"https://github.com/python/mypy/issues/8796"}
| 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:62d4534c-2fef-7804-64bb-619973b8d0d3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81DE:3E1398:5099E7:6BF228:6B002FF2 |
| html-safe-nonce | 803d6c4a6f3e3abb41570d324949627d249bcad9c7cc42b840c0f0200dcd9c2f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MURFOjNFMTM5ODo1MDk5RTc6NkJGMjI4OjZCMDAyRkYyIiwidmlzaXRvcl9pZCI6IjM2NTE1MzYzMTg3NDEwOTg0ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9edb8cc299837a0a1b051726c2f68269c39fbd3c4687ef3d87804001535aef60 |
| hovercard-subject-tag | issue:615843018 |
| 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/8796/issue_layout |
| twitter:image | https://opengraph.githubassets.com/52b9284f780342f6f522df56ec9b7c70e706ffe36539d4fa2e4345b279818c00/python/mypy/issues/8796 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/52b9284f780342f6f522df56ec9b7c70e706ffe36539d4fa2e4345b279818c00/python/mypy/issues/8796 |
| og:image:alt | Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would appreciate if you try to si... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AugPro |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width