Title: Unexpected behavior on using NamedTuple and Generic when bounding TypeVar in different ways · Issue #10672 · python/mypy · GitHub
Open Graph Title: Unexpected behavior on using NamedTuple and Generic when bounding TypeVar in different ways · Issue #10672 · python/mypy
X Title: Unexpected behavior on using NamedTuple and Generic when bounding TypeVar in different ways · Issue #10672 · python/mypy
Description: Crash Report / Traceback / To Reproduce I try to use NamedTuple and Generic such as the following code: # test.py from typing import (NamedTuple, Generic, TypeVar) S = TypeVar('S', bound='_S') class _S: pass class A(NamedTuple, Generic[S...
Open Graph Description: Crash Report / Traceback / To Reproduce I try to use NamedTuple and Generic such as the following code: # test.py from typing import (NamedTuple, Generic, TypeVar) S = TypeVar('S', bound='_S') clas...
X Description: Crash Report / Traceback / To Reproduce I try to use NamedTuple and Generic such as the following code: # test.py from typing import (NamedTuple, Generic, TypeVar) S = TypeVar('S', bound=...
Opengraph URL: https://github.com/python/mypy/issues/10672
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected behavior on using NamedTuple and Generic when bounding TypeVar in different ways","articleBody":"**Crash Report / Traceback / To Reproduce**\r\n\r\nI try to use NamedTuple and Generic such as the following code:\r\n```python\r\n# test.py\r\nfrom typing import (NamedTuple, Generic, TypeVar)\r\n\r\nS = TypeVar('S', bound='_S')\r\n\r\nclass _S:\r\n pass\r\n\r\nclass A(NamedTuple, Generic[S]):\r\n s: S\r\n```\r\n\r\nIn this case mypy raises an internal error:\r\n```\r\ntest.py:9: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.902\r\nTraceback (most recent call last):\r\n File \"mypy/semanal.py\", line 4872, in accept\r\n File \"mypy/nodes.py\", line 687, in accept\r\n File \"mypy/semanal.py\", line 577, in visit_func_def\r\n File \"mypy/semanal.py\", line 609, in analyze_func_def\r\n File \"mypy/semanal.py\", line 4583, in defer\r\nAssertionError: Must not defer during final iteration\r\ntest.py:9: : note: use --pdb to drop into pdb\r\n```\r\n\r\nBut mypy returns \"sucess\" with code 0 if I swap `class _S` and `S`:\r\n\r\n```python\r\n# test.py\r\nfrom typing import (NamedTuple, Generic, TypeVar)\r\n\r\nclass _S:\r\n pass\r\n\r\nS = TypeVar('S', bound='_S')\r\n\r\nclass A(NamedTuple, Generic[S]):\r\n s: S\r\n```\r\n\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.902\r\n- Mypy command-line flags: `mypy --show-traceback test.py`\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: 3.8.0\r\n- Operating system and version: Ubuntu 18.04.5","author":{"url":"https://github.com/yoyoLeeTW","@type":"Person","name":"yoyoLeeTW"},"datePublished":"2021-06-19T08:30:25Z","url":"https://github.com/python/mypy/issues/10672"}
| 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:12619c08-e8e3-f0b7-290a-8cfd0513a0db |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E26E:251AC0:B7540C:F326EF:6B0049BA |
| html-safe-nonce | 222940956dbbc54ad9f5fe04a32dadefba25ba0d2d44e81b043f6b097397ee79 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjZFOjI1MUFDMDpCNzU0MEM6RjMyNkVGOjZCMDA0OUJBIiwidmlzaXRvcl9pZCI6IjIwMjQyOTYzMjk4MTkyMTIyMTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 435faadade97018ed5182f4a48b3da6990f4fca237d2ff7e7b00d130e120bd58 |
| hovercard-subject-tag | issue:925346586 |
| 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/10672/issue_layout |
| twitter:image | https://opengraph.githubassets.com/197e772693c7b6bb10e1ff6a914055ef04bd070a710c18db05dff069c7e4afcd/python/mypy/issues/10672 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/197e772693c7b6bb10e1ff6a914055ef04bd070a710c18db05dff069c7e4afcd/python/mypy/issues/10672 |
| og:image:alt | Crash Report / Traceback / To Reproduce I try to use NamedTuple and Generic such as the following code: # test.py from typing import (NamedTuple, Generic, TypeVar) S = TypeVar('S', bound='_S') clas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yoyoLeeTW |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| 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 | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width