Skip to content

Commit 389ddea

Browse files
hauntsaninjapull[bot]
authored andcommitted
gh-115881: Document feature_version limitations (#115980)
1 parent 4b938d8 commit 389ddea

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Doc/library/ast.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,12 +2183,15 @@ and classes for traversing abstract syntax trees:
21832183
modified to correspond to :pep:`484` "signature type comments",
21842184
e.g. ``(str, int) -> List[str]``.
21852185

2186-
Also, setting ``feature_version`` to a tuple ``(major, minor)``
2187-
will attempt to parse using that Python version's grammar.
2188-
Currently ``major`` must equal to ``3``. For example, setting
2189-
``feature_version=(3, 4)`` will allow the use of ``async`` and
2190-
``await`` as variable names. The lowest supported version is
2191-
``(3, 7)``; the highest is ``sys.version_info[0:2]``.
2186+
Setting ``feature_version`` to a tuple ``(major, minor)`` will result in
2187+
a "best-effort" attempt to parse using that Python version's grammar.
2188+
For example, setting ``feature_version=(3, 9)`` will attempt to disallow
2189+
parsing of :keyword:`match` statements.
2190+
Currently ``major`` must equal to ``3``. The lowest supported version is
2191+
``(3, 7)`` (and this may increase in future Python versions);
2192+
the highest is ``sys.version_info[0:2]``. "Best-effort" attempt means there
2193+
is no guarantee that the parse (or success of the parse) is the same as
2194+
when run on the Python version corresponding to ``feature_version``.
21922195

21932196
If source contains a null character ('\0'), :exc:`ValueError` is raised.
21942197

0 commit comments

Comments
 (0)