Title: Fail fast if special module like typing not from typeshed · Issue #1876 · python/mypy · GitHub
Open Graph Title: Fail fast if special module like typing not from typeshed · Issue #1876 · python/mypy
X Title: Fail fast if special module like typing not from typeshed · Issue #1876 · python/mypy
Description: mypy generally crashes with an internal error if it winds up trying to handle a file named typing.py, apparently due to confusion with the built-in typing module. Here's the simplest test case I've found (tested on 0.4.3 and master): (my...
Open Graph Description: mypy generally crashes with an internal error if it winds up trying to handle a file named typing.py, apparently due to confusion with the built-in typing module. Here's the simplest test case I've...
X Description: mypy generally crashes with an internal error if it winds up trying to handle a file named typing.py, apparently due to confusion with the built-in typing module. Here's the simplest test case ...
Opengraph URL: https://github.com/python/mypy/issues/1876
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fail fast if special module like typing not from typeshed","articleBody":"mypy generally crashes with an internal error if it winds up trying to handle a file named `typing.py`, apparently due to confusion with the built-in `typing` module. Here's the simplest test case I've found (tested on 0.4.3 and master):\n\n```\n(mypyve) vm:/tmp/test1$ cat typing.py \nfrom collections import namedtuple\n\nx = namedtuple('x', [])\n(mypyve) vm:/tmp/test1$ mypy -s typing.py \nTraceback (most recent call last):\n File \"/tmp/mypyve/bin/mypy\", line 6, in \u003cmodule>\n main(__file__)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 40, in main\n res = type_check_only(sources, bin_dir, options)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 81, in type_check_only\n options=options)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 177, in build\n dispatch(sources, manager)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1338, in dispatch\n process_graph(graph, manager)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1481, in process_graph\n process_stale_scc(graph, scc)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1554, in process_stale_scc\n graph[id].semantic_analysis()\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1303, in semantic_analysis\n self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 243, in visit_file\n self.accept(d)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 2307, in accept\n node.accept(self)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/nodes.py\", line 761, in accept\n return visitor.visit_assignment_stmt(self)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1076, in visit_assignment_stmt\n self.process_namedtuple_definition(s)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1416, in process_namedtuple_definition\n named_tuple = self.check_namedtuple(s.rvalue, name)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1454, in check_namedtuple\n info = self.build_namedtuple_typeinfo(name, items, types)\n File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1543, in build_namedtuple_typeinfo\n info.mro = [info] + info.tuple_type.fallback.type.mro\nTypeError: can only concatenate list (not \"NoneType\") to list\n\n*** INTERNAL ERROR ***\n\ntyping.py:3: error: Internal error -- please report a bug at https://github.com/python/mypy/issues\n\nNOTE: you can use \"mypy --pdb ...\" to drop into the debugger when this happens.\n```\n\nThis is the same error message reported in a comment in #1293. The root cause is that mypy ships a file called typing.py in site-packages, so if site-packages winds up on the path (even implicitly, even with -s), it dies:\n\n```\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ mypy -s typing.py \nTraceback (most recent call last):\n...\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ touch hello.py\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ mypy -s hello.py \nTraceback (most recent call last):\n...\n```\n\nThis makes it impossible to analyze a package along with even a subset of its dependencies as the implicit addition to MYPYPATH results in an internal error.\n","author":{"url":"https://github.com/drakedevel","@type":"Person","name":"drakedevel"},"datePublished":"2016-07-15T20:05:57Z","url":"https://github.com/python/mypy/issues/1876"}
| 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:a54627fd-a375-39ac-0eb7-2e18655588ac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A000:CF959:309CC21:401B102:6B0023FE |
| html-safe-nonce | 4dd0d190188350c0d6ab3ef4a41839efcbd18333266bd26303ddf44436e06d8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDAwOkNGOTU5OjMwOUNDMjE6NDAxQjEwMjo2QjAwMjNGRSIsInZpc2l0b3JfaWQiOiI2ODg4NTA0NjYxNjI4Nzc0MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c66deb1a50e85cb921aebca9cd6a5bafa231139eac88c3427d2b1cfa03560078 |
| hovercard-subject-tag | issue:165867141 |
| 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/1876/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbf18413b50fdb22f38b3cec1acd4a97f9cc367cf15fbb18c8adad7fc1c4dc7f/python/mypy/issues/1876 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbf18413b50fdb22f38b3cec1acd4a97f9cc367cf15fbb18c8adad7fc1c4dc7f/python/mypy/issues/1876 |
| og:image:alt | mypy generally crashes with an internal error if it winds up trying to handle a file named typing.py, apparently due to confusion with the built-in typing module. Here's the simplest test case I've... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | drakedevel |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width