From 159566e1a01353dbb80078a3f7f9149d560150d5 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 16 Sep 2023 18:10:25 +0100 Subject: [PATCH 1/4] Add Python 3.12 as a tested platform --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2cb23ac..a565425d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,8 @@ jobs: strategy: matrix: os: [ubuntu-20.04, windows-2019] - python-version: ["3.11", "3.10", "3.9", "3.8", "3.7", "3.6"] - environment: ['3.8', '3.11', '3.10', '3.9', '3.7', '3.6', 'interpreter'] + python-version: ["3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"] + environment: ['3.8', '3.12', '3.11', '3.10', '3.9', '3.7', '3.6', 'interpreter'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -19,10 +19,12 @@ jobs: if: ${{ matrix.environment != 'interpreter' }} with: python-version: ${{ matrix.environment }} + allow-prereleases: true - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + allow-prereleases: true - name: Install dependencies run: 'pip install .[testing]' From 29890c1f2911026a2a7b3b32391f75ade06a9c51 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 16 Sep 2023 18:08:33 +0100 Subject: [PATCH 2/4] Ignore linux-only os.CLONE_* constants in Python 3.12 in import test --- test/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_utils.py b/test/test_utils.py index c6b8011c..f17fc246 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -81,7 +81,7 @@ class TestSetupReadline(unittest.TestCase): if all(not x.startswith('from os import ' + s) for s in ['_', 'O_', 'EX_', 'MFD_', 'SF_', 'ST_', 'CLD_', 'POSIX_SPAWN_', 'P_', 'RWF_', - 'SCHED_']) + 'CLONE_', 'SCHED_']) } # There are quite a few differences, because both Windows and Linux # (posix and nt) libraries are included. From 770cdade00dfdd5114f55f6d4a40a88bee315140 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 16 Sep 2023 19:27:51 +0100 Subject: [PATCH 3/4] Claim support for Python 3.12 --- CHANGELOG.rst | 2 ++ jedi/api/environment.py | 2 +- jedi/inference/__init__.py | 2 +- setup.py | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 05bf2c85..3f43d622 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,8 @@ Changelog Unreleased ++++++++++ +- Python 3.12 support + 0.19.0 (2023-07-29) +++++++++++++++++++ diff --git a/jedi/api/environment.py b/jedi/api/environment.py index bd1806c6..771a9a83 100644 --- a/jedi/api/environment.py +++ b/jedi/api/environment.py @@ -17,7 +17,7 @@ import parso _VersionInfo = namedtuple('VersionInfo', 'major minor micro') # type: ignore[name-match] -_SUPPORTED_PYTHONS = ['3.11', '3.10', '3.9', '3.8', '3.7', '3.6'] +_SUPPORTED_PYTHONS = ['3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6'] _SAFE_PATHS = ['/usr/bin', '/usr/local/bin'] _CONDA_VAR = 'CONDA_PREFIX' _CURRENT_VERSION = '%s.%s' % (sys.version_info.major, sys.version_info.minor) diff --git a/jedi/inference/__init__.py b/jedi/inference/__init__.py index 7ebeb79f..aadfeba9 100644 --- a/jedi/inference/__init__.py +++ b/jedi/inference/__init__.py @@ -90,7 +90,7 @@ class InferenceState: self.compiled_subprocess = environment.get_inference_state_subprocess(self) self.grammar = environment.get_grammar() - self.latest_grammar = parso.load_grammar(version='3.11') + self.latest_grammar = parso.load_grammar(version='3.12') self.memoize_cache = {} # for memoize decorators self.module_cache = imports.ModuleCache() # does the job of `sys.modules`. self.stub_module_cache = {} # Dict[Tuple[str, ...], Optional[ModuleValue]] diff --git a/setup.py b/setup.py index ebb3f639..dad15342 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup(name='jedi', long_description=readme, packages=find_packages(exclude=['test', 'test.*']), python_requires='>=3.6', - # Python 3.11 grammar is added to parso in 0.8.3 + # Python 3.11 & 3.12 grammars are added to parso in 0.8.3 install_requires=['parso>=0.8.3,<0.9.0'], extras_require={ 'testing': [ @@ -97,6 +97,7 @@ setup(name='jedi', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Editors :: Integrated Development Environments (IDE)', 'Topic :: Utilities', From a60fdba1d460f98e15f74a3c83079c74451f4116 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sun, 17 Sep 2023 18:24:59 +0100 Subject: [PATCH 4/4] Adjust for change to documention change of `next` in Python 3.12 The signature of the builtin isn't actually changing in Python 3.12, however its documentation has changed. --- test/test_inference/test_compiled.py | 6 +++++- test/test_inference/test_signature.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test_inference/test_compiled.py b/test/test_inference/test_compiled.py index e0315e52..b762135d 100644 --- a/test/test_inference/test_compiled.py +++ b/test/test_inference/test_compiled.py @@ -1,4 +1,5 @@ from textwrap import dedent +import sys import math from collections import Counter from datetime import datetime @@ -26,7 +27,10 @@ def test_builtin_loading(inference_state): assert not from_name.py__doc__() # It's a stub -def test_next_docstr(inference_state): +def test_next_docstr(inference_state, environment): + if environment.version_info[:2] != sys.version_info[:2]: + pytest.skip() + next_ = compiled.builtin_from_name(inference_state, 'next') assert next_.tree_node is not None assert next_.py__doc__() == '' # It's a stub diff --git a/test/test_inference/test_signature.py b/test/test_inference/test_signature.py index 4ade46e4..766fdd24 100644 --- a/test/test_inference/test_signature.py +++ b/test/test_inference/test_signature.py @@ -13,7 +13,8 @@ from ..helpers import get_example_dir 'code, sig, names, op, version', [ ('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 6)), - ('next', 'next(iterator, default=None, /)', ['iterator', 'default'], ge, (3, 6)), + ('next', 'next(iterator, default=None, /)', ['iterator', 'default'], lt, (3, 12)), + ('next', 'next()', [], ge, (3, 12)), ('str', "str(object='', /) -> str", ['object'], ge, (3, 6)),