You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When forgetting to wrap parentheses around the arguments of a function with python2 style annotations, the fast-parser crashes but the default parser does not.
Example:
deff(a, b):
# type: int, int -> intreturna+b
Expected behavior:
mypy --py2 testcase.py
testcase.py: note: In function "f":
testcase.py:1: error: Parse error before "int"
Actual behavior:
mypy --py2 --fast-parser testcase.py
Traceback (most recent call last):
File "/Users/cdean/.virtualenvs/mypy/bin/mypy", line 6, in <module>
main(__file__)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/main.py", line 54, in main
res = type_check_only(sources, bin_dir, options)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/main.py", line 102, in type_check_only
python_path=options.python_path)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 209, in build
dispatch(sources, manager)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1319, in dispatch
graph = load_graph(sources, manager)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1334, in load_graph
st = State(id=bs.module, path=bs.path, source=bs.text, manager=manager)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1106, in __init__
self.parse_file()
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1217, in parse_file
self.tree = manager.parse_file(self.id, self.xpath, source)
File "/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1175, in wrap_context
report_internal_error(err, self.path, 0)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1171, in wrap_context
yield
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 1217, in parse_file
self.tree = manager.parse_file(self.id, self.xpath, source)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/build.py", line 449, in parse_file
fast_parser=FAST_PARSER in self.flags)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/parse.py", line 88, in parse
custom_typing_module=custom_typing_module)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 69, in parse
).visit(ast)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/typed_ast/ast35.py", line 252, in visit
return visitor(node)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 221, in visit_Module
body = self.fix_function_overloads(self.visit_list(mod.body))
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 122, in visit_list
return [self.visit(e) for e in l]
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 122, in <listcomp>
return [self.visit(e) for e in l]
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/typed_ast/ast35.py", line 252, in visit
return visitor(node)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 90, in wrapper
node = f(self, ast)
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/mypy/fastparse.py", line 242, in visit_FunctionDef
func_type_ast = ast35.parse(n.type_comment, '<func_type>', 'func_type')
File "/Users/cdean/.virtualenvs/mypy/lib/python3.5/site-packages/typed_ast/ast35.py", line 42, in parse
return _ast35._parse(source, filename, mode)
SyntaxError: invalid syntax (<func_type>, line 1)
*** INTERNAL ERROR ***
testcase.py: error: Internal error -- please report a bug at https://github.com/python/mypy/issues
NOTE: you can use "mypy --pdb ..." to drop into the debugger when this happens.
When forgetting to wrap parentheses around the arguments of a function with python2 style annotations, the fast-parser crashes but the default parser does not.
Example:
Expected behavior:
Actual behavior:
Versions:
on Python 3.5.0
The text was updated successfully, but these errors were encountered: