Title: Wrong file blamed for a mixture of NamedTuple and passing a function instead of type. · Issue #8511 · python/mypy · GitHub
Open Graph Title: Wrong file blamed for a mixture of NamedTuple and passing a function instead of type. · Issue #8511 · python/mypy
X Title: Wrong file blamed for a mixture of NamedTuple and passing a function instead of type. · Issue #8511 · python/mypy
Description: Are you reporting a bug, or opening a feature request? bug Please insert below the code you are checking with mypy, Create an empty dir/init.py. Create dir/file1.py with: import typing def foo(): pass Type1 = typing.NamedTuple('Type1', [...
Open Graph Description: Are you reporting a bug, or opening a feature request? bug Please insert below the code you are checking with mypy, Create an empty dir/init.py. Create dir/file1.py with: import typing def foo(): p...
X Description: Are you reporting a bug, or opening a feature request? bug Please insert below the code you are checking with mypy, Create an empty dir/init.py. Create dir/file1.py with: import typing def foo(): p...
Opengraph URL: https://github.com/python/mypy/issues/8511
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong file blamed for a mixture of NamedTuple and passing a function instead of type.","articleBody":"* Are you reporting a bug, or opening a feature request?\r\nbug\r\n\r\n* Please insert below the code you are checking with mypy,\r\n * Create an empty dir/__init__.py.\r\n * Create dir/file1.py with:\r\n```\r\nimport typing\r\n\r\ndef foo():\r\n pass\r\n\r\n\r\nType1 = typing.NamedTuple('Type1', [\r\n ('foo', foo),\r\n])\r\n```\r\n * Create file2.py (in the root dir) with:\r\n```\r\nfrom typing import NamedTuple\r\n\r\nfrom dir.file1 import Type1\r\n\r\nType2 = NamedTuple('Type2', [\r\n ('x', Type1),\r\n])\r\n```\r\n * Run: mypy file2.py --follow-imports=silent\r\n\r\n* What is the actual behavior/output?\r\n\r\nThe error message is:\r\nfile2.py:8: error: Name 'foo' is not defined\r\n\r\n-> Note that file2.py has no line 8 (it the problematic line in file1.py) and no mention of `foo`.\r\n\r\n* What is the behavior/output you expect?\r\n * the error message should point to file1.py or say something about Type1 in file2.py being invalid.\r\n * foo is well defined in this case, making the error message more cryptic.\r\n\r\nWhen reducing this case I've found that removing --follow-import-silent gives an error message about file1.py which is actionable, but the other message is still present and is wrong, since the line number refers to a line in file1.py.\r\n\r\n* What are the versions of mypy and Python you are using?\r\n\r\nmypy 0.761 on Python 3.5.2\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\n\r\n--follow-imports=silent\r\n","author":{"url":"https://github.com/mikolajz","@type":"Person","name":"mikolajz"},"datePublished":"2020-03-07T21:09:42Z","url":"https://github.com/python/mypy/issues/8511"}
| 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:952f404d-e241-c50f-cd5f-7b040a69435e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 86FE:283776:E97008:1385BFF:6B005726 |
| html-safe-nonce | b932c0fc90de3b558f3679ea95ff796a13bdc779b28b078bb63c7008b67c119b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkZFOjI4Mzc3NjpFOTcwMDg6MTM4NUJGRjo2QjAwNTcyNiIsInZpc2l0b3JfaWQiOiIzMTY3MzQwOTc3MzA4MzI1NjcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0f2f542263f70009dc75fd8549332f4699ad31a2e7ebdcd920e050c19226dd29 |
| hovercard-subject-tag | issue:577400858 |
| 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/8511/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9a78a026aee9fb5a7e16c50ec6c63c7594b534b39c00736829f5084cdd2ca10/python/mypy/issues/8511 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9a78a026aee9fb5a7e16c50ec6c63c7594b534b39c00736829f5084cdd2ca10/python/mypy/issues/8511 |
| og:image:alt | Are you reporting a bug, or opening a feature request? bug Please insert below the code you are checking with mypy, Create an empty dir/init.py. Create dir/file1.py with: import typing def foo(): p... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mikolajz |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width