From 67e0bec597e7218944e00e5dd26ce4a34bd05e74 Mon Sep 17 00:00:00 2001 From: Peter Law Date: Mon, 13 Feb 2023 19:34:30 +0000 Subject: [PATCH] Support Python 3.11 This adds support for targetting Python 3.11 via picking up the latest grammar from parso while also validating support for running on 3.11 by adding it to the CI matrix. --- .github/workflows/ci.yml | 4 ++-- jedi/api/environment.py | 2 +- jedi/inference/__init__.py | 2 +- setup.py | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c017b9ea..bf7664d3 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.10", "3.9", "3.8", "3.7", "3.6"] - environment: ['3.8', '3.10', '3.9', '3.7', '3.6', 'interpreter'] + 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'] steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/jedi/api/environment.py b/jedi/api/environment.py index b2fc5b2c..bd1806c6 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.10', '3.9', '3.8', '3.7', '3.6'] +_SUPPORTED_PYTHONS = ['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 f7b6019e..adf8531f 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.10') + self.latest_grammar = parso.load_grammar(version='3.11') 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 b050500b..513850e7 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,8 @@ setup(name='jedi', long_description=readme, packages=find_packages(exclude=['test', 'test.*']), python_requires='>=3.6', - install_requires=['parso>=0.8.0,<0.9.0'], + # Python 3.11 grammar is added to parso in 0.8.3 + install_requires=['parso>=0.8.3,<0.9.0'], extras_require={ 'testing': [ 'pytest<7.0.0', @@ -95,6 +96,7 @@ setup(name='jedi', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Editors :: Integrated Development Environments (IDE)', 'Topic :: Utilities',