5 Commits
Author SHA1 Message Date
Dave Halter be9f5a401f Prepare release 0.8.5
Build / lint (push) Has been cancelled
Build / test (false, 3.10) (push) Has been cancelled
Build / test (false, 3.11) (push) Has been cancelled
Build / test (false, 3.12) (push) Has been cancelled
Build / test (false, 3.13) (push) Has been cancelled
Build / test (false, 3.8) (push) Has been cancelled
Build / test (false, 3.9) (push) Has been cancelled
Build / coverage (push) Has been cancelled
2025-08-23 17:12:20 +02:00
Dave Halter 7e4777b775 Merge pull request #234 from A5rocks/future-compatibility
Load newest grammar in face of a future grammar
2025-08-23 15:09:10 +00:00
A5rocks e99dbdd536 Remove redundant warnings import 2025-08-23 17:00:06 +09:00
A5rocks e22dc67aa1 Avoid warning 2025-08-23 16:38:08 +09:00
A5rocks baa3c90d85 Load newest grammar in face of a future grammar 2025-08-22 23:35:46 +09:00
5 changed files with 29 additions and 7 deletions
+5
View File
@@ -6,6 +6,11 @@ Changelog
Unreleased
++++++++++
0.8.5 (2025-08-23)
++++++++++++++++++
- Add a fallback grammar for Python 3.14+
0.8.4 (2024-04-05)
++++++++++++++++++
+1 -1
View File
@@ -43,7 +43,7 @@ from parso.grammar import Grammar, load_grammar
from parso.utils import split_lines, python_bytes_to_unicode
__version__ = '0.8.4'
__version__ = '0.8.5'
def parse(code=None, **kwargs):
+10 -1
View File
@@ -239,7 +239,16 @@ def load_grammar(*, version: str = None, path: str = None):
:param str version: A python version string, e.g. ``version='3.8'``.
:param str path: A path to a grammar file
"""
version_info = parse_version_string(version)
# NOTE: this (3, 14) should be updated to the latest version parso supports.
# (if this doesn't happen, users will get older syntaxes and spurious warnings)
passed_version_info = parse_version_string(version)
version_info = min(passed_version_info, PythonVersionInfo(3, 14))
# # NOTE: this is commented out until parso properly supports newer Python grammars.
# if passed_version_info != version_info:
# warnings.warn('parso does not support %s.%s yet.' % (
# passed_version_info.major, passed_version_info.minor
# ))
file = path or os.path.join(
'python',
+3
View File
@@ -10,3 +10,6 @@ norecursedirs = .* docs scripts normalizer_issue_files build
# fine as long as we are using `clean_jedi_cache` as a session scoped
# fixture.
usefixtures = clean_parso_cache
# Disallow warnings
filterwarnings = error
+10 -5
View File
@@ -4,15 +4,20 @@ from parso import utils
def test_load_inexisting_grammar():
# This version shouldn't be out for a while, but if we ever do, wow!
with pytest.raises(NotImplementedError):
load_grammar(version='15.8')
# The same is true for very old grammars (even though this is probably not
# going to be an issue.
# We support future grammars assuming future compatibility,
# but we don't know how to parse old grammars.
with pytest.raises(NotImplementedError):
load_grammar(version='1.5')
def test_load_grammar_uses_older_syntax():
load_grammar(version='4.0')
def test_load_grammar_doesnt_warn(each_version):
load_grammar(version=each_version)
@pytest.mark.parametrize(('string', 'result'), [
('2', (2, 7)), ('3', (3, 6)), ('1.1', (1, 1)), ('1.1.1', (1, 1)), ('300.1.31', (300, 1))
])