@@ -225,15 +225,25 @@ import_stmt[stmt_ty](memo):
225225# -----------------
226226
227227import_name[stmt_ty]:
228- | lazy="lazy"? 'import' a=dotted_as_names { _PyAST_Import(a, lazy ? 1 : 0, EXTRA) }
228+ | "lazy" 'import' a=dotted_as_names {
229+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
230+ _PyAST_Import(a, 1, EXTRA)) }
231+ | 'import' a=dotted_as_names { _PyAST_Import(a, 0, EXTRA) }
229232
230233# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
231234import_from[stmt_ty]:
232235 | invalid_import_from
233- | lazy="lazy"? 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
234- _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA) }
235- | lazy="lazy"? 'from' a=('.' | '...')+ 'import' b=import_from_targets {
236- _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0, EXTRA) }
236+ | lazy="lazy" 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
237+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
238+ _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA)) }
239+ | "lazy" 'from' a=('.' | '...')+ 'import' b=import_from_targets {
240+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
241+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 1, EXTRA)) }
242+ | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
243+ _PyPegen_checked_from_import(p, a, b, c, NULL, EXTRA) }
244+ | 'from' a=('.' | '...')+ 'import' b=import_from_targets {
245+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 0, EXTRA) }
246+
237247import_from_targets[asdl_alias_seq*]:
238248 | '(' a=import_from_as_names [','] ')' { a }
239249 | import_from_as_names !','
0 commit comments