@@ -225,14 +225,24 @@ 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]:
232- | lazy="lazy"? 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
233- _PyPegen_checked_future_import(p, b->v.Name.id, c, _PyPegen_seq_count_dots(a), lazy, EXTRA) }
234- | lazy="lazy"? 'from' a=('.' | '...')+ 'import' b=import_from_targets {
235- _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0, EXTRA) }
235+ | lazy="lazy" 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
236+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
237+ _PyPegen_checked_future_import(p, b->v.Name.id, c, _PyPegen_seq_count_dots(a), lazy, EXTRA)) }
238+ | "lazy" 'from' a=('.' | '...')+ 'import' b=import_from_targets {
239+ CHECK_VERSION(stmt_ty, 15, "Lazy imports are",
240+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 1, EXTRA)) }
241+ | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
242+ _PyPegen_checked_future_import(p, b->v.Name.id, c, _PyPegen_seq_count_dots(a), 0, EXTRA) }
243+ | 'from' a=('.' | '...')+ 'import' b=import_from_targets {
244+ _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), 0, EXTRA) }
245+
236246import_from_targets[asdl_alias_seq*]:
237247 | '(' a=import_from_as_names [','] ')' { a }
238248 | import_from_as_names !','
0 commit comments