Title: NamedTuple with no fields causes `"object" not callable` error · Issue #1276 · python/mypy · GitHub
Open Graph Title: NamedTuple with no fields causes `"object" not callable` error · Issue #1276 · python/mypy
X Title: NamedTuple with no fields causes `"object" not callable` error · Issue #1276 · python/mypy
Description: Blue = NamedTuple("Blue", []) Fails with: example.py:5: error: "object" not callable But this code runs fine in python2/python3. Edit: Seems like it's falling out to here a bit odd to me because NamedTuple does indeed have a __call__ att...
Open Graph Description: Blue = NamedTuple("Blue", []) Fails with: example.py:5: error: "object" not callable But this code runs fine in python2/python3. Edit: Seems like it's falling out to here a bit odd to me because Na...
X Description: Blue = NamedTuple("Blue", []) Fails with: example.py:5: error: "object" not callable But this code runs fine in python2/python3. Edit: Seems like it's falling out to here a ...
Opengraph URL: https://github.com/python/mypy/issues/1276
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NamedTuple with no fields causes `\"object\" not callable` error","articleBody":"``` python\nBlue = NamedTuple(\"Blue\", [])\n```\n\nFails with:\n\n``` python\nexample.py:5: error: \"object\" not callable\n```\n\nBut this code runs fine in python2/python3.\n\n**Edit**: \nSeems like it's falling out to [here](https://github.com/python/mypy/blob/e308f2f786d432577286e0d84abaca505d02ec81/mypy/checkmember.py#L160)\na bit odd to me because NamedTuple does indeed have a `__call__` attribute\n\nInteresting. The following fails:\n\n``` python\nalist = [('afield', str)]\nGreen = NamedTuple(\"Green\", alist)\n\nexample.py:3: error: List literal expected as the second argument to namedtuple()\nexample.py:3: error: \"object\" not callable\n```\n\nBut this works:\n\n``` python\nGreen = NamedTuple(\"Green\", [('afields', str)])\n```\n\nI think the `type_map` is storing `NameExpr(NamedTuple [typing.NamedTuple])` as an `object`, and it looks like the in the latter case it's skipping a check . . . I remember reading in an issue that NamedTuple wasn't fully supported, so I assume that's what's going on.\n","author":{"url":"https://github.com/averagehat","@type":"Person","name":"averagehat"},"datePublished":"2016-03-06T17:29:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1276/mypy/issues/1276"}
| 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:98675eb0-aa14-889b-3f5c-513ce43c6300 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD8C:8CEA6:1019C1C:1775BC8:6A575B21 |
| html-safe-nonce | 82660694015416974d70d763d506af5ea2c453cbe9e3f73d119d633e3d245a1a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDhDOjhDRUE2OjEwMTlDMUM6MTc3NUJDODo2QTU3NUIyMSIsInZpc2l0b3JfaWQiOiI3Nzg3MjAxNDMwODg1NDU2NjczIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5dec553134e6e7b286884cfb38bf4ee76a6787df3c1dcf0222125cb632ff4b6a |
| hovercard-subject-tag | issue:138813583 |
| 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/1276/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9a5e9e6a17a5a4665464580a4acaa7ceaab15f15d151c2502bffddd947b1fd9/python/mypy/issues/1276 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9a5e9e6a17a5a4665464580a4acaa7ceaab15f15d151c2502bffddd947b1fd9/python/mypy/issues/1276 |
| og:image:alt | Blue = NamedTuple("Blue", []) Fails with: example.py:5: error: "object" not callable But this code runs fine in python2/python3. Edit: Seems like it's falling out to here a bit odd to me because Na... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | averagehat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| 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 | 87685a1c739dbf97e95760413799bb0221799457 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width