Open
Description
Bug report
Bug description:
The level
field on ast.ImportFrom
is marked optional in the ASDL definition, but in fact the parser always sets it:
>>> ast.dump(ast.parse('from x import a'))
"Module(body=[ImportFrom(module='x', names=[alias(name='a')], level=0)])"
>>> ast.dump(ast.parse('from .x import a'))
"Module(body=[ImportFrom(module='x', names=[alias(name='a')], level=1)])"
>>> ast.dump(ast.parse('from ...............x import a'))
"Module(body=[ImportFrom(module='x', names=[alias(name='a')], level=15)])"
We should mark the field as required for consistency with the parser.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS