-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
In bpo-35766, Guido merged the "typed_ast" code that mypy used to maintain back into main CPython parser. This means that starting in 3.8, the regular ast module will contain information on type comments and type: ignore comments.
The type: ignore comments are stored in a list on the ast.Module object. This list is now mandatory. That means that this code is broken:
ipython/IPython/core/interactiveshell.py
Lines 3191 to 3192 in 512d473
| mod = ast.Module(nodelist) | |
| async_wrapper_code = compiler(mod, 'cell_name', 'exec') |
So is this:
ipython/IPython/core/interactiveshell.py
Lines 3199 to 3200 in 512d473
| mod = ast.Module([node]) | |
| code = compiler(mod, cell_name, "exec") |
[BTW, why does one of those say 'cell_name' and the other says cell_name? Seems like one of those must be wrong... CC: @Carreau]
When you create a Module like this and try to compile it, then you get:
TypeError: required field "type_ignores" missing from Module
On 3.8+, to create a Module object you have to instead write ast.Module(nodelist, []).
I filed a bug on python (bpo-35894), and Guido responded that the details of the AST like this aren't considered stable API, so he considers this a bug for IPython to fix, not a regression on CPython. So, now I'm filing a bug here instead :-).
The full changes are here, and AFAICT this line is the one that's breaking IPython.