Title: NamedTuple subclasses do not pick up __new__'s signature · Issue #5194 · python/mypy · GitHub
Open Graph Title: NamedTuple subclasses do not pick up __new__'s signature · Issue #5194 · python/mypy
X Title: NamedTuple subclasses do not pick up __new__'s signature · Issue #5194 · python/mypy
Description: mypy inspects the field names instead of looking at the signature of __new__. (I didn't try __init__, that wasn't my use case.) Mypy 0.610, Python 3.6.3. Not tried Mypy from git master (haven't checked how to do that). Code: #! /usr/bin/...
Open Graph Description: mypy inspects the field names instead of looking at the signature of __new__. (I didn't try __init__, that wasn't my use case.) Mypy 0.610, Python 3.6.3. Not tried Mypy from git master (haven't che...
X Description: mypy inspects the field names instead of looking at the signature of __new__. (I didn't try __init__, that wasn't my use case.) Mypy 0.610, Python 3.6.3. Not tried Mypy from git master (hav...
Opengraph URL: https://github.com/python/mypy/issues/5194
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NamedTuple subclasses do not pick up __new__'s signature","articleBody":"mypy inspects the field names instead of looking at the signature of `__new__`.\r\n(I didn't try `__init__`, that wasn't my use case.)\r\n\r\nMypy 0.610, Python 3.6.3.\r\nNot tried Mypy from git master (haven't checked how to do that).\r\n\r\nCode:\r\n\r\n```Python\r\n#! /usr/bin/env python3\r\n\r\nfrom typing import List, NamedTuple\r\n\r\nclass Command(NamedTuple):\r\n subcommands: List[str]\r\n\r\nclass HelpCommand(Command):\r\n def __new__(cls):\r\n return Command.__new__(cls, subcommands=[])\r\n\r\nHelpCommand() # fails in mypy, works in Python\r\nHelpCommand(subcommands=[]) # works in mypy, fails in Python\r\n```\r\n\r\nCommand: `python3 -m mypy typetest.py`\r\n\r\nOutput:\r\n```\r\ntypetest.py:12: error: Too few arguments for \"HelpCommand\"\r\n```\r\n\r\nPython has a different idea about what should work and what shouldn't:\r\n\r\n```\r\n$ ./typetest.py \r\nTraceback (most recent call last):\r\n File \"./typetest.py\", line 12, in \u003cmodule>\r\n HelpCommand(subcommands=[]) # works\r\nTypeError: __new__() got an unexpected keyword argument 'subcommands'\r\n```","author":{"url":"https://github.com/toolforger","@type":"Person","name":"toolforger"},"datePublished":"2018-06-11T06:08:00Z","url":"https://github.com/python/mypy/issues/5194"}
| 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:3afb60cf-5066-6d0b-0bed-e44c6f270040 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 918A:07D0:207FDC6:2B0BD16:6B004EA7 |
| html-safe-nonce | 63d0100dbcba93776bdad29b29f08f160dec86b6b69b90c911b626142e6d6eca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MThBOjA3RDA6MjA3RkRDNjoyQjBCRDE2OjZCMDA0RUE3IiwidmlzaXRvcl9pZCI6IjI1MzMwNjY3NzgzMzUwMDYzNzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 750dfa7fbe7703f51518e01ed36c1e7bc0ab3d23ad3f17e4124702daa46d42e7 |
| hovercard-subject-tag | issue:331056176 |
| 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/5194/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84911bfe18e92105be925ade64435d94a1527258a90dee26f6991aa041d89048/python/mypy/issues/5194 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84911bfe18e92105be925ade64435d94a1527258a90dee26f6991aa041d89048/python/mypy/issues/5194 |
| og:image:alt | mypy inspects the field names instead of looking at the signature of __new__. (I didn't try __init__, that wasn't my use case.) Mypy 0.610, Python 3.6.3. Not tried Mypy from git master (haven't che... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | toolforger |
| 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