{"action":"created","issue":{"url":"https://api.github.com/repos/python/mypy/issues/1876","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/1876/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/1876/comments","events_url":"https://api.github.com/repos/python/mypy/issues/1876/events","html_url":"https://github.com/python/mypy/issues/1876","id":165867141,"number":1876,"title":"Several issues with files named `typing.py`","user":{"login":"drakedevel","id":403067,"avatar_url":"https://avatars.githubusercontent.com/u/403067?v=3","gravatar_id":"","url":"https://api.github.com/users/drakedevel","html_url":"https://github.com/drakedevel","followers_url":"https://api.github.com/users/drakedevel/followers","following_url":"https://api.github.com/users/drakedevel/following{/other_user}","gists_url":"https://api.github.com/users/drakedevel/gists{/gist_id}","starred_url":"https://api.github.com/users/drakedevel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drakedevel/subscriptions","organizations_url":"https://api.github.com/users/drakedevel/orgs","repos_url":"https://api.github.com/users/drakedevel/repos","events_url":"https://api.github.com/users/drakedevel/events{/privacy}","received_events_url":"https://api.github.com/users/drakedevel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python/mypy/labels/Crash","name":"Crash","color":"b60205"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/python/mypy/milestones/5","html_url":"https://github.com/python/mypy/milestones/0.4.x","labels_url":"https://api.github.com/repos/python/mypy/milestones/5/labels","id":1616634,"number":5,"title":"0.4.x","description":"The next release, and the next, within 0.4.x.\r\n\r\n(This is not strictly a milestone, just issues we'd like to get to before 0.5.0. For now we're going to a 6-week release cadence. So since 0.4.3 went out on July 14, 0.4.4 should go out on August 25.","creator":{"login":"ddfisher","id":245905,"avatar_url":"https://avatars.githubusercontent.com/u/245905?v=3","gravatar_id":"","url":"https://api.github.com/users/ddfisher","html_url":"https://github.com/ddfisher","followers_url":"https://api.github.com/users/ddfisher/followers","following_url":"https://api.github.com/users/ddfisher/following{/other_user}","gists_url":"https://api.github.com/users/ddfisher/gists{/gist_id}","starred_url":"https://api.github.com/users/ddfisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddfisher/subscriptions","organizations_url":"https://api.github.com/users/ddfisher/orgs","repos_url":"https://api.github.com/users/ddfisher/repos","events_url":"https://api.github.com/users/ddfisher/events{/privacy}","received_events_url":"https://api.github.com/users/ddfisher/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":31,"state":"open","created_at":"2016-03-01T23:19:26Z","updated_at":"2016-07-15T20:52:45Z","due_on":"2016-08-25T07:00:00Z","closed_at":null},"comments":8,"created_at":"2016-07-15T20:05:57Z","updated_at":"2016-07-15T22:34:39Z","closed_at":null,"body":"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):\r\n\r\n```\r\n(mypyve) vm:/tmp/test1$ cat typing.py \r\nfrom collections import namedtuple\r\n\r\nx = namedtuple('x', [])\r\n(mypyve) vm:/tmp/test1$ mypy -s typing.py \r\nTraceback (most recent call last):\r\n  File \"/tmp/mypyve/bin/mypy\", line 6, in <module>\r\n    main(__file__)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 40, in main\r\n    res = type_check_only(sources, bin_dir, options)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 81, in type_check_only\r\n    options=options)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 177, in build\r\n    dispatch(sources, manager)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1338, in dispatch\r\n    process_graph(graph, manager)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1481, in process_graph\r\n    process_stale_scc(graph, scc)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1554, in process_stale_scc\r\n    graph[id].semantic_analysis()\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1303, in semantic_analysis\r\n    self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 243, in visit_file\r\n    self.accept(d)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 2307, in accept\r\n    node.accept(self)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/nodes.py\", line 761, in accept\r\n    return visitor.visit_assignment_stmt(self)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1076, in visit_assignment_stmt\r\n    self.process_namedtuple_definition(s)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1416, in process_namedtuple_definition\r\n    named_tuple = self.check_namedtuple(s.rvalue, name)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1454, in check_namedtuple\r\n    info = self.build_namedtuple_typeinfo(name, items, types)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1543, in build_namedtuple_typeinfo\r\n    info.mro = [info] + info.tuple_type.fallback.type.mro\r\nTypeError: can only concatenate list (not \"NoneType\") to list\r\n\r\n*** INTERNAL ERROR ***\r\n\r\ntyping.py:3: error: Internal error -- please report a bug at https://github.com/python/mypy/issues\r\n\r\nNOTE: you can use \"mypy --pdb ...\" to drop into the debugger when this happens.\r\n```\r\n\r\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:\r\n\r\n```\r\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ mypy -s typing.py \r\nTraceback (most recent call last):\r\n...\r\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ touch hello.py\r\n(mypyve) vm:/tmp/mypyve/lib/python3.4/site-packages$ mypy -s hello.py \r\nTraceback (most recent call last):\r\n...\r\n```\r\n\r\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."},"comment":{"url":"https://api.github.com/repos/python/mypy/issues/comments/233085193","html_url":"https://github.com/python/mypy/issues/1876#issuecomment-233085193","issue_url":"https://api.github.com/repos/python/mypy/issues/1876","id":233085193,"user":{"login":"drakedevel","id":403067,"avatar_url":"https://avatars.githubusercontent.com/u/403067?v=3","gravatar_id":"","url":"https://api.github.com/users/drakedevel","html_url":"https://github.com/drakedevel","followers_url":"https://api.github.com/users/drakedevel/followers","following_url":"https://api.github.com/users/drakedevel/following{/other_user}","gists_url":"https://api.github.com/users/drakedevel/gists{/gist_id}","starred_url":"https://api.github.com/users/drakedevel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drakedevel/subscriptions","organizations_url":"https://api.github.com/users/drakedevel/orgs","repos_url":"https://api.github.com/users/drakedevel/repos","events_url":"https://api.github.com/users/drakedevel/events{/privacy}","received_events_url":"https://api.github.com/users/drakedevel/received_events","type":"User","site_admin":false},"created_at":"2016-07-15T22:34:39Z","updated_at":"2016-07-15T22:34:39Z","body":"Here's the case with that same typing.py alongside an empty hello.py with 0.4.3:\r\n\r\n```\r\n(app) vm:/tmp/test5$ cat typing.py \r\nfrom collections import namedtuple\r\nx = namedtuple('x', [])\r\n(app) vm:/tmp/test5$ cat hello.py \r\n(app) vm:/tmp/test5$ mypy --version\r\nmypy 0.4.3\r\n(app) vm:/tmp/test5$ mypy -sv hello.py \r\n0.000:LOG:  Using new dependency manager\r\n0.000:LOG:  Parsing hello.py (hello)\r\n0.001:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/builtins.pyi (builtins)\r\n0.077:LOG:  Parsing /tmp/test5/typing.py (typing)\r\n0.078:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/abc.pyi (abc)\r\n0.079:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/collections/__init__.pyi (collections)\r\n0.087:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/sys.pyi (sys)\r\n0.096:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/types.pyi (types)\r\n0.106:LOG:  Parsing /home/adrake/ve/app/lib/mypy/typeshed/stdlib/3/_importlib_modulespec.pyi (_importlib_modulespec)\r\n0.109:LOG:  Loaded graph with 8 nodes\r\n0.109:LOG:  Found 2 SCCs; largest has 7 nodes\r\n0.110:LOG:  Processing SCC of size 7 (collections abc typing _importlib_modulespec types sys builtins) as inherently stale (_importlib_modulespec abc builtins collections sys types typing)\r\nTraceback (most recent call last):\r\n  File \"/home/adrake/ve/app/bin/mypy\", line 6, in <module>\r\n    main(__file__)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/main.py\", line 40, in main\r\n    res = type_check_only(sources, bin_dir, options)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/main.py\", line 81, in type_check_only\r\n    options=options)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/build.py\", line 177, in build\r\n    dispatch(sources, manager)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/build.py\", line 1323, in dispatch\r\n    process_graph(graph, manager)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/build.py\", line 1461, in process_graph\r\n    process_stale_scc(graph, scc)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/build.py\", line 1534, in process_stale_scc\r\n    graph[id].semantic_analysis()\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/build.py\", line 1288, in semantic_analysis\r\n    self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 243, in visit_file\r\n    self.accept(d)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 2306, in accept\r\n    node.accept(self)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/nodes.py\", line 761, in accept\r\n    return visitor.visit_assignment_stmt(self)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 1075, in visit_assignment_stmt\r\n    self.process_namedtuple_definition(s)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 1415, in process_namedtuple_definition\r\n    named_tuple = self.check_namedtuple(s.rvalue, name)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 1453, in check_namedtuple\r\n    info = self.build_namedtuple_typeinfo(name, items, types)\r\n  File \"/home/adrake/ve/app/lib/python3.4/site-packages/mypy/semanal.py\", line 1542, in build_namedtuple_typeinfo\r\n    info.mro = [info] + info.tuple_type.fallback.type.mro\r\nTypeError: can only concatenate list (not \"NoneType\") to list\r\n\r\n*** INTERNAL ERROR ***\r\n\r\n/tmp/test5/typing.py:2: error: Internal error -- please report a bug at https://github.com/python/mypy/issues\r\n\r\nNOTE: you can use \"mypy --pdb ...\" to drop into the debugger when this happens.\r\n0.116:LOG:  Build finished with 8 modules, 0 types, and 57 errors\r\n(app) vm:/tmp/test5$ \r\n```\r\n\r\nAnd here's git master, same file setup:\r\n\r\n```\r\n(mypyve) vm:/tmp/test5$ mypy --version\r\nmypy 0.4.4-dev\r\n(mypyve) vm:/tmp/test5$ mypy -sv hello.py \r\n0.000:LOG:  Using new dependency manager\r\n0.000:LOG:  Parsing hello.py (hello)\r\n0.001:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/builtins.pyi (builtins)\r\n0.079:LOG:  Parsing /tmp/test5/typing.py (typing)\r\n0.080:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/abc.pyi (abc)\r\n0.081:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/collections/__init__.pyi (collections)\r\n0.089:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/sys.pyi (sys)\r\n0.096:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/types.pyi (types)\r\n0.107:LOG:  Parsing /tmp/mypyve/lib/mypy/typeshed/stdlib/3/_importlib_modulespec.pyi (_importlib_modulespec)\r\n0.110:LOG:  Loaded graph with 8 nodes\r\n0.110:LOG:  Found 2 SCCs; largest has 7 nodes\r\n0.110:LOG:  Processing SCC of size 7 (collections abc typing _importlib_modulespec types sys builtins) as inherently stale (_importlib_modulespec abc builtins collections sys types typing)\r\nTraceback (most recent call last):\r\n  File \"/tmp/mypyve/bin/mypy\", line 6, in <module>\r\n    main(__file__)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 40, in main\r\n    res = type_check_only(sources, bin_dir, options)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/main.py\", line 81, in type_check_only\r\n    options=options)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 177, in build\r\n    dispatch(sources, manager)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1338, in dispatch\r\n    process_graph(graph, manager)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1481, in process_graph\r\n    process_stale_scc(graph, scc)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1554, in process_stale_scc\r\n    graph[id].semantic_analysis()\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/build.py\", line 1303, in semantic_analysis\r\n    self.manager.semantic_analyzer.visit_file(self.tree, self.xpath)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 243, in visit_file\r\n    self.accept(d)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 2307, in accept\r\n    node.accept(self)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/nodes.py\", line 761, in accept\r\n    return visitor.visit_assignment_stmt(self)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1076, in visit_assignment_stmt\r\n    self.process_namedtuple_definition(s)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1416, in process_namedtuple_definition\r\n    named_tuple = self.check_namedtuple(s.rvalue, name)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1454, in check_namedtuple\r\n    info = self.build_namedtuple_typeinfo(name, items, types)\r\n  File \"/tmp/mypyve/lib/python3.4/site-packages/mypy/semanal.py\", line 1543, in build_namedtuple_typeinfo\r\n    info.mro = [info] + info.tuple_type.fallback.type.mro\r\nTypeError: can only concatenate list (not \"NoneType\") to list\r\n\r\n*** INTERNAL ERROR ***\r\n\r\n/tmp/test5/typing.py:2: error: Internal error -- please report a bug at https://github.com/python/mypy/issues\r\n\r\nNOTE: you can use \"mypy --pdb ...\" to drop into the debugger when this happens.\r\n0.116:LOG:  Build finished with 8 modules, 0 types, and 57 errors\r\n```"}}
{"actor":{"display_login":"drakedevel"}}