Title: "maximum semantic analysis iteration count reached" with TypeVar bound to recursive type definition · Issue #8320 · python/mypy · GitHub
Open Graph Title: "maximum semantic analysis iteration count reached" with TypeVar bound to recursive type definition · Issue #8320 · python/mypy
X Title: "maximum semantic analysis iteration count reached" with TypeVar bound to recursive type definition · Issue #8320 · python/mypy
Description: I encountered what appears to be a bug when using a TypeVar bound to a recursive type definition. Python 3.6.9 mypy 0.761, also master Simplified example code: from typing import Union, List, TypeVar SomethingWithWs = Union[str, List['So...
Open Graph Description: I encountered what appears to be a bug when using a TypeVar bound to a recursive type definition. Python 3.6.9 mypy 0.761, also master Simplified example code: from typing import Union, List, TypeV...
X Description: I encountered what appears to be a bug when using a TypeVar bound to a recursive type definition. Python 3.6.9 mypy 0.761, also master Simplified example code: from typing import Union, List, TypeV...
Opengraph URL: https://github.com/python/mypy/issues/8320
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"maximum semantic analysis iteration count reached\" with TypeVar bound to recursive type definition","articleBody":"I encountered what appears to be a bug when using a TypeVar bound to a recursive type definition.\r\n\r\n- Python 3.6.9\r\n- mypy 0.761, also master\r\n\r\nSimplified example code:\r\n```\r\nfrom typing import Union, List, TypeVar\r\n\r\nSomethingWithWs = Union[str, List['SomethingWithWs']]\r\n\r\nT = TypeVar('T', bound=SomethingWithWs)\r\n\r\n\r\ndef remove_w(data: T) -> T:\r\n if isinstance(data, str):\r\n return data.replace('w', '')\r\n elif isinstance(data, list):\r\n return [remove_w(d) for d in data]\r\n else:\r\n raise TypeError()\r\n```\r\n\r\nI ran the command:\r\n`mypy remove_w.py --show-traceback`\r\nwith no additional configuration file\r\n\r\nOutput:\r\n```\r\nDeferral trace:\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\n remove_w:3\r\n remove_w:3\r\n remove_w:-1\r\n remove_w:5\r\n remove_w:5\r\nremove_w.py: error: INTERNAL ERROR: maximum semantic analysis iteration count reached\r\nremove_w.py:8: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.761\r\nTraceback (most recent call last):\r\n File \"mypy/semanal.py\", line 4665, in accept\r\n File \"mypy/nodes.py\", line 676, in accept\r\n File \"mypy/semanal.py\", line 557, in visit_func_def\r\n File \"mypy/semanal.py\", line 586, in analyze_func_def\r\n File \"mypy/typeanal.py\", line 501, in visit_callable_type\r\n File \"mypy/typeanal.py\", line 867, in anal_var_defs\r\n File \"mypy/types.py\", line 1888, in accept\r\n File \"mypy/typeanal.py\", line 600, in visit_placeholder_type\r\n File \"mypy/semanal.py\", line 4399, in defer\r\nAssertionError: Must not defer during final iteration\r\nremove_w.py:8: : note: use --pdb to drop into pdb\r\n```","author":{"url":"https://github.com/brianmaissy","@type":"Person","name":"brianmaissy"},"datePublished":"2020-01-23T12:54:29Z","url":"https://github.com/python/mypy/issues/8320"}
| 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:1cb09932-5398-962f-603d-bfcb41b4956d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D25A:2261EB:140A1FB:1A40F9B:6B000A50 |
| html-safe-nonce | d898a973d4b49d2c7fe76a36a235547ed50896f2afac27e4846b043d90e1a0ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjVBOjIyNjFFQjoxNDBBMUZCOjFBNDBGOUI6NkIwMDBBNTAiLCJ2aXNpdG9yX2lkIjoiODEwMDAwNzM5NTE2NzU3MDUxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2af162d7bc350a1e91b4e482aaa8db15a0f8801a542066db46e139e76c66135a |
| hovercard-subject-tag | issue:554139393 |
| 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/8320/issue_layout |
| twitter:image | https://opengraph.githubassets.com/69416349545fa3d0821fab0319f07c5c48cb0579365d77b22e91b59a144744e2/python/mypy/issues/8320 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/69416349545fa3d0821fab0319f07c5c48cb0579365d77b22e91b59a144744e2/python/mypy/issues/8320 |
| og:image:alt | I encountered what appears to be a bug when using a TypeVar bound to a recursive type definition. Python 3.6.9 mypy 0.761, also master Simplified example code: from typing import Union, List, TypeV... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brianmaissy |
| 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