bpo-40334: Support type comments (GH-19780)
This implements full support for # type: <type> comments, # type: ignore <stuff> comments, and the func_type parsing mode for ast.parse() and compile(). Closes https://github.com/we-like-parsers/cpython/issues/95. (For now, you need to use the master branch of mypy, since another issue unique to 3.9 had to be fixed there, and there's no mypy release yet.) The only thing missing is `feature_version=N`, which is being tracked in https://github.com/we-like-parsers/cpython/issues/124.
This commit is contained in:
@@ -816,12 +816,8 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
|
||||
if (str == NULL)
|
||||
goto error;
|
||||
|
||||
int current_use_peg = PyInterpreterState_Get()->config._use_peg_parser;
|
||||
if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0 || compile_mode == 3) {
|
||||
PyInterpreterState_Get()->config._use_peg_parser = 0;
|
||||
}
|
||||
result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize);
|
||||
PyInterpreterState_Get()->config._use_peg_parser = current_use_peg;
|
||||
|
||||
Py_XDECREF(source_copy);
|
||||
goto finally;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user