>>> import ast
>>> ast.parse('lazy import os', feature_version=(3, 12))
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
ast.parse('lazy import os', feature_version=(3, 12))
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/cpython/Lib/ast.py", line 46, in parse
return compile(source, filename, mode, flags,
_feature_version=feature_version, optimize=optimize,
module=module)
File "<unknown>", line 1
lazy import os
^
SyntaxError: Lazy imports are only supported in Python 3.15 and greater
I have a PR ready.
Bug report
Code:
Works and parses
lazy importon older python versions :(It should produce something like:
I have a PR ready.
Linked PRs
ast.parseon lazy imports with olderfeature_version#152632