Skip to content

Commit

Permalink
Support Python 3.11 (#5226)
Browse files Browse the repository at this point in the history
* support python311

* review actions
  • Loading branch information
rcomer authored Apr 21, 2023
1 parent 619de4e commit d58fca7
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 98 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]
python-version: ["3.11"]
session: ["doctest", "gallery", "linkcheck"]
include:
- os: "ubuntu-latest"
python-version: "3.10"
python-version: "3.11"
session: "tests"
coverage: "--coverage"
- os: "ubuntu-latest"
python-version: "3.10"
session: "tests"
- os: "ubuntu-latest"
python-version: "3.9"
session: "tests"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
session: ["wheel"]
env:
ENV_NAME: "ci-wheels"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// * No build-time environment variables.
// * Is run in the same environment as the ASV install itself.
"delegated_env_commands": [
"PY_VER=3.10 nox --envdir={conf_dir}/.asv/env/nox01 --session=tests --install-only --no-error-on-external-run --verbose"
"PY_VER=3.11 nox --envdir={conf_dir}/.asv/env/nox01 --session=tests --install-only --no-error-on-external-run --verbose"
],
// The parent directory of the above environment.
// The most recently modified environment in the directory will be used.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bm_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _prep_data_gen_env() -> None:
"""

root_dir = BENCHMARKS_DIR.parent
python_version = "3.10"
python_version = "3.11"
data_gen_var = "DATA_GEN_PYTHON"
if data_gen_var in environ:
print("Using existing data generation environment.")
Expand Down
3 changes: 2 additions & 1 deletion docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ This document explains the changes made to Iris for this release
🔗 Dependencies
===============

#. N/A
#. `@rcomer`_ and `@bjlittle`_ (reviewer) added testing support for python
3.11. (:pull:`5226`)


📚 Documentation
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test_python_versions():
This test is designed to fail whenever Iris' supported Python versions are
updated, insisting that versions are updated EVERYWHERE in-sync.
"""
latest_supported = "3.10"
all_supported = ["3.8", "3.9", latest_supported]
latest_supported = "3.11"
all_supported = ["3.8", "3.9", "3.10", latest_supported]

root_dir = Path(__file__).parents[3]
workflows_dir = root_dir / ".github" / "workflows"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
# importing anything else.
import iris.tests as tests # isort:skip

from platform import python_version
from xml.dom import minidom

import numpy as np
from numpy import ma
from pkg_resources import parse_version

from iris._lazy_data import as_lazy_data, is_lazy_data
from iris.experimental.ugrid.mesh import Connectivity
Expand Down Expand Up @@ -61,10 +63,14 @@ def test_indices(self):

def test_read_only(self):
attributes = ("indices", "cf_role", "start_index", "location_axis")
if parse_version(python_version()) >= parse_version("3.11"):
msg = "object has no setter"
else:
msg = "can't set attribute"
for attribute in attributes:
self.assertRaisesRegex(
AttributeError,
"can't set attribute",
msg,
setattr,
self.connectivity,
attribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
# importing anything else.
import iris.tests as tests # isort:skip

from platform import python_version
import re
import unittest.mock as mock

import dask.array as da
import numpy as np
from pkg_resources import parse_version
import pytest

from iris._lazy_data import as_lazy_data, is_lazy_data
Expand Down Expand Up @@ -77,8 +79,12 @@ def setUp(self):
def test_fixed_metadata(self):
# Check that you cannot set any of these on an existing MeshCoord.
meshcoord = self.meshcoord
if parse_version(python_version()) >= parse_version("3.11"):
msg = "object has no setter"
else:
msg = "can't set attribute"
for prop in ("mesh", "location", "axis"):
with self.assertRaisesRegex(AttributeError, "can't set"):
with self.assertRaisesRegex(AttributeError, msg):
setattr(meshcoord, prop, mock.sentinel.odd)

def test_coord_system(self):
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
nox.options.reuse_existing_virtualenvs = True

#: Python versions we can run sessions under
_PY_VERSIONS_ALL = ["3.8", "3.9", "3.10"]
_PY_VERSIONS_ALL = ["3.8", "3.9", "3.10", "3.11"]
_PY_VERSION_LATEST = _PY_VERSIONS_ALL[-1]

#: One specific python version for docs builds
Expand Down
2 changes: 1 addition & 1 deletion requirements/iris.yml
Loading

0 comments on commit d58fca7

Please sign in to comment.