{"action":"closed","issue":{"url":"https://api.github.com/repos/python/mypy/issues/1931","repository_url":"https://api.github.com/repos/python/mypy","labels_url":"https://api.github.com/repos/python/mypy/issues/1931/labels{/name}","comments_url":"https://api.github.com/repos/python/mypy/issues/1931/comments","events_url":"https://api.github.com/repos/python/mypy/issues/1931/events","html_url":"https://github.com/python/mypy/issues/1931","id":167148661,"number":1931,"title":"Imports inside class causes crash when using silent imports and incremental","user":{"login":"Michael0x2a","id":1424628,"avatar_url":"https://avatars.githubusercontent.com/u/1424628?v=3","gravatar_id":"","url":"https://api.github.com/users/Michael0x2a","html_url":"https://github.com/Michael0x2a","followers_url":"https://api.github.com/users/Michael0x2a/followers","following_url":"https://api.github.com/users/Michael0x2a/following{/other_user}","gists_url":"https://api.github.com/users/Michael0x2a/gists{/gist_id}","starred_url":"https://api.github.com/users/Michael0x2a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Michael0x2a/subscriptions","organizations_url":"https://api.github.com/users/Michael0x2a/orgs","repos_url":"https://api.github.com/users/Michael0x2a/repos","events_url":"https://api.github.com/users/Michael0x2a/events{/privacy}","received_events_url":"https://api.github.com/users/Michael0x2a/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-22T23:04:04Z","updated_at":"2016-07-25T18:53:16Z","closed_at":"2016-07-25T18:53:16Z","body":"Consider the following file:\r\n\r\n**test.py**\r\n\r\n```python\r\nclass MyObject(object):\r\n    from foo import FooBar\r\n```\r\n\r\nRunning `mypy --silent-imports --incremental test.py` twice will cause the following crash on the second run:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py\", line 184, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/Users/michaellee/Work/mypy/mypy/__main__.py\", line 5, in <module>\r\n    main(None)\r\n  File \"/Users/michaellee/Work/mypy/mypy/main.py\", line 40, in main\r\n    res = type_check_only(sources, bin_dir, options)\r\n  File \"/Users/michaellee/Work/mypy/mypy/main.py\", line 81, in type_check_only\r\n    options=options)\r\n  File \"/Users/michaellee/Work/mypy/mypy/build.py\", line 178, in build\r\n    dispatch(sources, manager)\r\n  File \"/Users/michaellee/Work/mypy/mypy/build.py\", line 1325, in dispatch\r\n    process_graph(graph, manager)\r\n  File \"/Users/michaellee/Work/mypy/mypy/build.py\", line 1466, in process_graph\r\n    process_fresh_scc(graph, scc)\r\n  File \"/Users/michaellee/Work/mypy/mypy/build.py\", line 1525, in process_fresh_scc\r\n    graph[id].fix_cross_refs()\r\n  File \"/Users/michaellee/Work/mypy/mypy/build.py\", line 1188, in fix_cross_refs\r\n    fixup_module_pass_one(self.tree, self.manager.modules)\r\n  File \"/Users/michaellee/Work/mypy/mypy/fixup.py\", line 17, in fixup_module_pass_one\r\n    node_fixer.visit_symbol_table(tree.names)\r\n  File \"/Users/michaellee/Work/mypy/mypy/fixup.py\", line 82, in visit_symbol_table\r\n    self.visit_type_info(value.node)\r\n  File \"/Users/michaellee/Work/mypy/mypy/fixup.py\", line 51, in visit_type_info\r\n    self.visit_symbol_table(info.names)\r\n  File \"/Users/michaellee/Work/mypy/mypy/fixup.py\", line 75, in visit_symbol_table\r\n    stnode = lookup_qualified_stnode(self.modules, cross_ref)\r\n  File \"/Users/michaellee/Work/mypy/mypy/fixup.py\", line 247, in lookup_qualified_stnode\r\n    assert key in names, \"Cannot find %s for %s\" % (key, name)\r\nAssertionError: Cannot find FooBar for test.FooBar\r\n```\r\n\r\nMypy reports no errors if you get rid of the `--silent-imports` flag (and add the `foo.py` file).\r\n\r\nThis may possibly be related to https://github.com/python/mypy/issues/1839."}}
{"actor":{"display_login":"gvanrossum"}}