Skip to content

Exception in partial_type.type #1747

Closed
@twk

Description

@twk

I got this error parsing a large file:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/mypy", line 6, in
main(file)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/main.py", line 55, in main
res = type_check_only(sources, bin_dir, options)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/main.py", line 103, in type_check_only
python_path=options.python_path)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 217, in build
dispatch(sources, manager)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1353, in dispatch
process_graph(graph, manager)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1486, in process_graph
process_stale_scc(graph, scc)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1516, in process_stale_scc
graph[id].type_check()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/build.py", line 1333, in type_check
manager.type_checker.visit_file(self.tree, self.xpath)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 430, in visit_file
self.accept(d)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 650, in accept
return visitor.visit_class_def(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1069, in visit_class_def
self.accept(defn.defs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 713, in accept
return visitor.visit_block(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1164, in visit_block
self.accept(s)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 534, in accept
return visitor.visit_decorator(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1973, in visit_decorator
e.func.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 465, in accept
return visitor.visit_func_def(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 592, in visit_func_def
self.check_func_item(defn, name=defn.name())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 650, in check_func_item
self.check_func_def(defn, typ, name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 759, in check_func_def
self.accept_in_frame(item.body)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 494, in accept_in_frame
answer = self.accept(node, type_context)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 713, in accept
return visitor.visit_block(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1164, in visit_block
self.accept(s)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 727, in accept
return visitor.visit_expression_stmt(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 1603, in visit_expression_stmt
self.accept(s.expr)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 479, in accept
typ = node.accept(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/nodes.py", line 1183, in accept
return visitor.visit_call_expr(self)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checker.py", line 2035, in visit_call_expr
return self.expr_checker.visit_call_expr(e)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 136, in visit_call_expr
self.try_infer_partial_type(e)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mypy/checkexpr.py", line 160, in try_infer_partial_type
if partial_type.type is None:
AttributeError: 'NoneType' object has no attribute 'type'

The referenced line of code was the second one here:

results.sort(cmp=lambda x, y: cmp(x[0], y[0]))
results = [x[1] for x in results]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions