Skip to content

Commit e668f2a

Browse files
authored
Recognize Python 3.14 parser config (#1452)
1 parent 2dc435f commit e668f2a

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

libcst/_parser/tests/test_config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ def test_pick_compatible(self) -> None:
1818
PythonVersionInfo(3, 1), _pick_compatible_python_version("3.1")
1919
)
2020
self.assertEqual(
21-
PythonVersionInfo(3, 8), _pick_compatible_python_version("3.9")
21+
PythonVersionInfo(3, 9), _pick_compatible_python_version("3.9")
2222
)
2323
self.assertEqual(
24-
PythonVersionInfo(3, 8), _pick_compatible_python_version("3.10")
24+
PythonVersionInfo(3, 10), _pick_compatible_python_version("3.10")
2525
)
2626
self.assertEqual(
27-
PythonVersionInfo(3, 8), _pick_compatible_python_version("4.0")
27+
PythonVersionInfo(3, 14), _pick_compatible_python_version("3.14")
28+
)
29+
self.assertEqual(
30+
PythonVersionInfo(3, 14), _pick_compatible_python_version("4.0")
2831
)
2932
with self.assertRaisesRegex(
3033
ValueError,

libcst/_parser/types/config.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,21 @@ def __repr__(self) -> str:
4444

4545

4646
# This list should be kept in sorted order.
47-
KNOWN_PYTHON_VERSION_STRINGS = ["3.0", "3.1", "3.3", "3.5", "3.6", "3.7", "3.8"]
47+
KNOWN_PYTHON_VERSION_STRINGS = [
48+
"3.0",
49+
"3.1",
50+
"3.3",
51+
"3.5",
52+
"3.6",
53+
"3.7",
54+
"3.8",
55+
"3.9",
56+
"3.10",
57+
"3.11",
58+
"3.12",
59+
"3.13",
60+
"3.14",
61+
]
4862

4963

5064
@add_slots
@@ -75,7 +89,8 @@ class PartialParserConfig:
7589
#: If unspecified, it will default to the syntax of the running interpreter
7690
#: (rounding down from among the following list).
7791
#:
78-
#: Currently, only Python 3.0, 3.1, 3.3, 3.5, 3.6, 3.7 and 3.8 syntax is supported.
92+
#: Currently, only Python 3.0, 3.1, 3.3, and Python 3.5 through 3.14
93+
#: syntax is supported.
7994
#: The gaps did not have any syntax changes from the version prior.
8095
python_version: Union[str, AutoConfig] = AutoConfig.token
8196

0 commit comments

Comments
 (0)