Skip to content

Commit

Permalink
Merge pull request #1956 from PeterJCLaw/python-3.12
Browse files Browse the repository at this point in the history
Support Python 3.12
  • Loading branch information
davidhalter authored Sep 17, 2023
2 parents 7e533ca + a60fdba commit 0770372
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changelog
Unreleased
++++++++++

- Python 3.12 support

0.19.0 (2023-07-29)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion jedi/api/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

_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)
Expand Down
2 changes: 1 addition & 1 deletion jedi/inference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, project, environment=None, script_path=None):
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]]
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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': [
Expand Down Expand Up @@ -97,6 +97,7 @@
'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',
Expand Down
6 changes: 5 additions & 1 deletion test/test_inference/test_compiled.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from textwrap import dedent
import sys
import math
from collections import Counter
from datetime import datetime
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/test_inference/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
'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)),
Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_import(self):
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.
Expand Down

0 comments on commit 0770372

Please sign in to comment.