-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
We ran into a mypy crash in Zulip, which was fixed with the following patch:
[email protected](name='render_markdown_path', is_safe=True)
# Much of the time, render_markdown_path is called with hashable
# arguments, so this decorator is effective even though it only caches
# the results when called if none of the arguments are unhashable.
@ignore_unhashable_lru_cache(512)
[email protected](name='render_markdown_path', is_safe=True)
def render_markdown_path(markdown_file_path, context=None):
# type: (str, Optional[Dict[Any, Any]]) -> str
"""Given a path to a markdown file, return the rendered html.
The traceback (with long source paths abbreviated):
zerver/templatetags/app_filters.py: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.560
Traceback (most recent call last):
File "/srv/zulip-py3-venv/bin/mypy", line 11, in <module>
sys.exit(console_entry())
File ".../site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File ".../site-packages/mypy/main.py", line 66, in main
res = type_check_only(sources, bin_dir, options)
File ".../site-packages/mypy/main.py", line 119, in type_check_only
options=options)
File ".../site-packages/mypy/build.py", line 218, in build
graph = dispatch(sources, manager)
File ".../site-packages/mypy/build.py", line 1997, in dispatch
process_graph(graph, manager)
File ".../site-packages/mypy/build.py", line 2299, in process_graph
process_stale_scc(graph, scc, manager)
File ".../site-packages/mypy/build.py", line 2486, in process_stale_scc
graph[id].finish_passes()
File ".../site-packages/mypy/build.py", line 1912, in finish_passes
manager.report_file(self.tree, self.type_map(), self.options)
File "/usr/lib/python3.4/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File ".../site-packages/mypy/build.py", line 1675, in wrap_context
yield
File ".../site-packages/mypy/build.py", line 1912, in finish_passes
manager.report_file(self.tree, self.type_map(), self.options)
File ".../site-packages/mypy/build.py", line 681, in report_file
self.reports.file(file, type_map, options)
File ".../site-packages/mypy/report.py", line 73, in file
reporter.on_file(tree, type_map, options)
File ".../site-packages/mypy/report.py", line 347, in on_file
tree.accept(coverage_visitor)
File ".../site-packages/mypy/nodes.py", line 228, in accept
return visitor.visit_mypy_file(self)
File ".../site-packages/mypy/traverser.py", line 30, in visit_mypy_file
d.accept(self)
File ".../site-packages/mypy/nodes.py", line 573, in accept
return visitor.visit_decorator(self)
File ".../site-packages/mypy/traverser.py", line 64, in visit_decorator
o.func.accept(self)
File ".../site-packages/mypy/nodes.py", line 497, in accept
return visitor.visit_func_def(self)
File ".../site-packages/mypy/report.py", line 317, in visit_func_def
assert start_indent is not None and start_indent > old_indent
AssertionError:
zerver/templatetags/app_filters.py: : note: use --pdb to drop into pdb
So it looks like we got confused by the line after the decorator being neither a definition nor the next decorator, but instead a comment.