Skip to content

Commit 16b53ac

Browse files
keewisdcherianpre-commit-ci[bot]
authored
drop support for python=3.9 (#8937)
* bump python in the min versions environments * bump python in ci * package metadata * docs * typo (This paragraph says it should be revisited after the bump) * tell `ruff` the target version is 3.10 * apply `pre-commit` hooks * automatically fix `UP038` * remove obsolete version checks * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ignore what's left of UP007 * Force numpy>=2 --------- Co-authored-by: Deepak Cherian <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Deepak Cherian <[email protected]>
1 parent 7cfad41 commit 16b53ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+280
-314
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ jobs:
139139
fail_ci_if_error: false
140140

141141
mypy39:
142-
name: Mypy 3.9
142+
name: Mypy 3.10
143143
runs-on: "ubuntu-latest"
144144
needs: detect-ci-trigger
145145
defaults:
146146
run:
147147
shell: bash -l {0}
148148
env:
149149
CONDA_ENV_FILE: ci/requirements/environment.yml
150-
PYTHON_VERSION: "3.9"
150+
PYTHON_VERSION: "3.10"
151151

152152
steps:
153153
- uses: actions/checkout@v4
@@ -254,7 +254,7 @@ jobs:
254254
fail_ci_if_error: false
255255

256256
pyright39:
257-
name: Pyright 3.9
257+
name: Pyright 3.10
258258
runs-on: "ubuntu-latest"
259259
needs: detect-ci-trigger
260260
if: |
@@ -267,7 +267,7 @@ jobs:
267267
shell: bash -l {0}
268268
env:
269269
CONDA_ENV_FILE: ci/requirements/environment.yml
270-
PYTHON_VERSION: "3.9"
270+
PYTHON_VERSION: "3.10"
271271

272272
steps:
273273
- uses: actions/checkout@v4

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ jobs:
4747
matrix:
4848
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
4949
# Bookend python versions
50-
python-version: ["3.9", "3.12"]
50+
python-version: ["3.10", "3.12"]
5151
env: [""]
5252
include:
5353
# Minimum python version:
5454
- env: "bare-minimum"
55-
python-version: "3.9"
55+
python-version: "3.10"
5656
os: ubuntu-latest
5757
- env: "min-all-deps"
58-
python-version: "3.9"
58+
python-version: "3.10"
5959
os: ubuntu-latest
6060
# Latest python version:
6161
- env: "all-but-dask"

ci/requirements/bare-minimum.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- nodefaults
55
dependencies:
6-
- python=3.9
6+
- python=3.10
77
- coveralls
88
- pip
99
- pytest

ci/requirements/min-all-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
# Run ci/min_deps_check.py to verify that this file respects the policy.
88
# When upgrading python, numpy, or pandas, must also change
99
# doc/user-guide/installing.rst, doc/user-guide/plotting.rst and setup.py.
10-
- python=3.9
10+
- python=3.10
1111
- array-api-strict=1.0 # dependency for testing the array api compat
1212
- boto3=1.26
1313
- bottleneck=1.3

doc/getting-started-guide/installing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Installation
66
Required dependencies
77
---------------------
88

9-
- Python (3.9 or later)
9+
- Python (3.10 or later)
1010
- `numpy <https://www.numpy.org/>`__ (1.23 or later)
1111
- `packaging <https://packaging.pypa.io/en/latest/#>`__ (23.1 or later)
1212
- `pandas <https://pandas.pydata.org/>`__ (2.0 or later)

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ classifiers = [
99
"Intended Audience :: Science/Research",
1010
"Programming Language :: Python",
1111
"Programming Language :: Python :: 3",
12-
"Programming Language :: Python :: 3.9",
1312
"Programming Language :: Python :: 3.10",
1413
"Programming Language :: Python :: 3.11",
1514
"Programming Language :: Python :: 3.12",
@@ -20,7 +19,7 @@ dynamic = ["version"]
2019
license = {text = "Apache-2.0"}
2120
name = "xarray"
2221
readme = "README.md"
23-
requires-python = ">=3.9"
22+
requires-python = ">=3.10"
2423

2524
dependencies = [
2625
"numpy>=1.23",
@@ -242,7 +241,7 @@ extend-exclude = [
242241
"doc",
243242
"_typed_ops.pyi",
244243
]
245-
target-version = "py39"
244+
target-version = "py310"
246245

247246
[tool.ruff.lint]
248247
# E402: module level import not at top of file
@@ -255,6 +254,7 @@ ignore = [
255254
"E402",
256255
"E501",
257256
"E731",
257+
"UP007"
258258
]
259259
select = [
260260
"F", # Pyflakes

xarray/backends/api.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
from __future__ import annotations
22

33
import os
4-
from collections.abc import Hashable, Iterable, Mapping, MutableMapping, Sequence
4+
from collections.abc import (
5+
Callable,
6+
Hashable,
7+
Iterable,
8+
Mapping,
9+
MutableMapping,
10+
Sequence,
11+
)
512
from functools import partial
613
from io import BytesIO
714
from numbers import Number
815
from typing import (
916
TYPE_CHECKING,
1017
Any,
11-
Callable,
1218
Final,
1319
Literal,
1420
Union,
@@ -358,7 +364,7 @@ def _dataset_from_backend_dataset(
358364
from_array_kwargs,
359365
**extra_tokens,
360366
):
361-
if not isinstance(chunks, (int, dict)) and chunks not in {None, "auto"}:
367+
if not isinstance(chunks, int | dict) and chunks not in {None, "auto"}:
362368
raise ValueError(
363369
f"chunks must be an int, dict, 'auto', or None. Instead found {chunks}."
364370
)
@@ -385,7 +391,7 @@ def _dataset_from_backend_dataset(
385391
if "source" not in ds.encoding:
386392
path = getattr(filename_or_obj, "path", filename_or_obj)
387393

388-
if isinstance(path, (str, os.PathLike)):
394+
if isinstance(path, str | os.PathLike):
389395
ds.encoding["source"] = _normalize_path(path)
390396

391397
return ds
@@ -1042,7 +1048,7 @@ def open_mfdataset(
10421048
raise OSError("no files to open")
10431049

10441050
if combine == "nested":
1045-
if isinstance(concat_dim, (str, DataArray)) or concat_dim is None:
1051+
if isinstance(concat_dim, str | DataArray) or concat_dim is None:
10461052
concat_dim = [concat_dim] # type: ignore[assignment]
10471053

10481054
# This creates a flat list which is easier to iterate over, whilst

xarray/backends/h5netcdf_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class H5NetCDFStore(WritableCFDataStore):
109109
def __init__(self, manager, group=None, mode=None, lock=HDF5_LOCK, autoclose=False):
110110
import h5netcdf
111111

112-
if isinstance(manager, (h5netcdf.File, h5netcdf.Group)):
112+
if isinstance(manager, h5netcdf.File | h5netcdf.Group):
113113
if group is None:
114114
root, group = find_root_and_group(manager)
115115
else:
@@ -374,7 +374,7 @@ def guess_can_open(
374374
if magic_number is not None:
375375
return magic_number.startswith(b"\211HDF\r\n\032\n")
376376

377-
if isinstance(filename_or_obj, (str, os.PathLike)):
377+
if isinstance(filename_or_obj, str | os.PathLike):
378378
_, ext = os.path.splitext(filename_or_obj)
379379
return ext in {".nc", ".nc4", ".cdf"}
380380

xarray/backends/lru_cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import threading
44
from collections import OrderedDict
5-
from collections.abc import Iterator, MutableMapping
6-
from typing import Any, Callable, TypeVar
5+
from collections.abc import Callable, Iterator, MutableMapping
6+
from typing import Any, TypeVar
77

88
K = TypeVar("K")
99
V = TypeVar("V")

xarray/backends/netCDF4_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def guess_can_open(
615615
# netcdf 3 or HDF5
616616
return magic_number.startswith((b"CDF", b"\211HDF\r\n\032\n"))
617617

618-
if isinstance(filename_or_obj, (str, os.PathLike)):
618+
if isinstance(filename_or_obj, str | os.PathLike):
619619
_, ext = os.path.splitext(filename_or_obj)
620620
return ext in {".nc", ".nc4", ".cdf"}
621621

0 commit comments

Comments
 (0)