@@ -218,15 +218,25 @@ import_stmt[stmt_ty](memo):
218218# -----------------
219219
220220import_name[stmt_ty]:
221- | lazy="lazy"? 'import' a=dotted_as_names { _PyAST_Import(a, lazy ? 1 : 0, EXTRA) }
221+ | "lazy" 'import' a=dotted_as_names {
222+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
223+ _PyAST_Import(a, 1, EXTRA)) }
224+ | 'import' a=dotted_as_names { _PyAST_Import(a, 0, EXTRA) }
222225
223226# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
224227import_from[stmt_ty]:
225228 | invalid_import_from
226- | lazy="lazy"? 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
227- _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA) }
228- | lazy="lazy"? 'from' a=('.' | '...')+ 'import' b=import_from_targets {
229- _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0, EXTRA) }
229+ | lazy="lazy" 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
230+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
231+ _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA)) }
232+ | "lazy" 'from' a=('.' | '...')+ 'import' b=import_from_targets {
233+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
234+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 1, EXTRA)) }
235+ | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
236+ _PyPegen_checked_from_import(p, a, b, c, NULL, EXTRA) }
237+ | 'from' a=('.' | '...')+ 'import' b=import_from_targets {
238+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 0, EXTRA) }
239+
230240import_from_targets[asdl_alias_seq*]:
231241 | '(' a=import_from_as_names [','] ')' { a }
232242 | import_from_as_names !','
0 commit comments