-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Internal error with generic type and alias using import * #2315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Reproduced. |
Another example that raises the issue without generic type: file ex2a.py from typing import Dict
Row = Dict[str, int] file ex2.py from ex2a import *
def do_something(dic: Row) -> None:
pass results in : mypy --show-traceback ex2.py
ex2.py:1: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues
Traceback (most recent call last):
File "/usr/local/bin/mypy", line 6, in <module>
main(__file__)
File "/usr/local/lib/python3.5/site-packages/mypy/main.py", line 38, in main
res = type_check_only(sources, bin_dir, options)
File "/usr/local/lib/python3.5/site-packages/mypy/main.py", line 79, in type_check_only
options=options)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 181, in build
dispatch(sources, manager)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1470, in dispatch
process_graph(graph, manager)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1650, in process_graph
process_stale_scc(graph, scc)
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1723, in process_stale_scc
graph[id].semantic_analysis_pass_three()
File "/usr/local/lib/python3.5/site-packages/mypy/build.py", line 1406, in semantic_analysis_pass_three
self.manager.semantic_analyzer_pass3.visit_file(self.tree, self.xpath, self.options)
File "/usr/local/lib/python3.5/site-packages/mypy/semanal.py", line 2770, in visit_file
self.accept(file_node)
File "/usr/local/lib/python3.5/site-packages/mypy/semanal.py", line 2774, in accept
node.accept(self)
File "/usr/local/lib/python3.5/site-packages/mypy/nodes.py", line 216, in accept
return visitor.visit_mypy_file(self)
File "/usr/local/lib/python3.5/site-packages/mypy/traverser.py", line 29, in visit_mypy_file
d.accept(self)
File "/usr/local/lib/python3.5/site-packages/mypy/nodes.py", line 507, in accept
return visitor.visit_func_def(self)
File "/usr/local/lib/python3.5/site-packages/mypy/semanal.py", line 2785, in visit_func_def
self.analyze(fdef.type)
File "/usr/local/lib/python3.5/site-packages/mypy/semanal.py", line 2871, in analyze
type.accept(analyzer)
File "/usr/local/lib/python3.5/site-packages/mypy/types.py", line 639, in accept
return visitor.visit_callable_type(self)
File "/usr/local/lib/python3.5/site-packages/mypy/typeanal.py", line 381, in visit_callable_type
arg_type.accept(self)
AttributeError: 'NoneType' object has no attribute 'accept'
ex2.py:1: note: use --pdb to drop into pdb |
Note that in the previous example, if you replace |
I'm thinking the issue has to do with "import *" mistreating certain types and aliases. |
gvanrossum
pushed a commit
that referenced
this issue
Nov 14, 2016
Fixes #2315 Fixes #2172 There were reported some crashes of mypy when using import * and type aliases (only two above issues seem to be still open, others are closed as duplicates). It looks like this is because visit_import_all in semanal.py does not copy type_override for imported nodes (visit_import_from does, so that the crashes reported happen only with import *). I added few tests based on (extended) examples discussed in bug reports. Since the reason is clear and the fix is straightforward (one line) I think more sophisticated tests are not required.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dang, I'm on a bug roll today. :D
In
x.py
:y.py
:Output:
The text was updated successfully, but these errors were encountered: