Skip to content

Commit c4d662e

Browse files
Bump to py3.9, test py3.12 (#475)
* Bump to py3.9, test py3.12 * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * cleanup warnings / speed up * Silence warning * Bump sphinx * Handle the `_deprecate_positional_kwargs` decorator * Add min xarray * Typing fixes * revert one * More bumps * update RTD yaml * fix? * skip unshallow fetch * try again * install local cf-xarray * try again * print sphinx version * see if furo in pip overrides * yet agauin * again * Switich ot py 3.10 * try typing * try again * update pypi workflow --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e3254bd commit c4d662e

File tree

16 files changed

+63
-97
lines changed

16 files changed

+63
-97
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
os: ["ubuntu-latest"]
30-
python-version: ["3.8", "3.11"]
30+
python-version: ["3.9", "3.12"]
3131
steps:
3232
- uses: actions/checkout@v4
3333
with:
@@ -58,47 +58,6 @@ jobs:
5858
name: codecov-umbrella
5959
fail_ci_if_error: false
6060

61-
old-xarray:
62-
name: xarray 2022.03.0
63-
runs-on: "ubuntu-latest"
64-
defaults:
65-
run:
66-
shell: bash -l {0}
67-
strategy:
68-
fail-fast: false
69-
matrix:
70-
python-version: ["3.10"]
71-
steps:
72-
- uses: actions/checkout@v4
73-
with:
74-
fetch-depth: 0 # Fetch all history for all branches and tags.
75-
- name: Set environment variables
76-
run: |
77-
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
78-
- name: Set up conda environment
79-
uses: mamba-org/provision-with-micromamba@v15
80-
with:
81-
environment-file: ci/environment.yml
82-
environment-name: cf_xarray_test
83-
cache-env: true
84-
extra-specs: |
85-
python="${{ matrix.python-version }}"
86-
xarray="2022.03.0"
87-
- name: Install cf_xarray
88-
run: |
89-
python -m pip install --no-deps -e .
90-
- name: Run Tests
91-
run: |
92-
pytest -n auto --cov=./ --cov-report=xml
93-
- name: Upload code coverage to Codecov
94-
uses: codecov/[email protected]
95-
with:
96-
file: ./coverage.xml
97-
flags: unittests
98-
env_vars: RUNNER_OS,PYTHON_VERSION
99-
name: codecov-umbrella
100-
fail_ci_if_error: false
101-
10261
no-optional-deps:
10362
name: no-optional-deps
10463
runs-on: ubuntu-latest
@@ -132,7 +91,7 @@ jobs:
13291
shell: bash -l {0}
13392
strategy:
13493
matrix:
135-
python-version: ["3.8", "3.11"]
94+
python-version: ["3.9", "3.12"]
13695
steps:
13796
- uses: actions/checkout@v4
13897
with:

.github/workflows/pypi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/setup-python@v4
1919
name: Install Python
2020
with:
21-
python-version: 3.8
21+
python-version: 3.10
2222

2323
- name: Install dependencies
2424
run: |
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/setup-python@v4
5454
name: Install Python
5555
with:
56-
python-version: 3.8
56+
python-version: 3.10
5757
- uses: actions/download-artifact@v3
5858
with:
5959
name: releases

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ ci:
22
autoupdate_schedule: quarterly
33

44
repos:
5+
- repo: https://github.com/asottile/pyupgrade
6+
rev: v3.15.0
7+
hooks:
8+
- id: pyupgrade
9+
args: ["--py39-plus"]
10+
511
- repo: https://github.com/astral-sh/ruff-pre-commit
612
# Ruff version.
713
rev: 'v0.1.1'

.readthedocs.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
# Required
21
version: 2
32

43
build:
5-
os: 'ubuntu-20.04'
4+
os: ubuntu-22.04
65
tools:
7-
python: 'mambaforge-4.10'
6+
python: mambaforge-4.10
7+
jobs:
8+
post_checkout:
9+
- (git --no-pager log --pretty="tformat:%s" -1 | grep -vqF "[skip-rtd]") || exit 183
10+
pre_install:
11+
- conda list sphinx
12+
- conda list cf_xarray
813

9-
# Build documentation in the docs/ directory with Sphinx
10-
sphinx:
11-
configuration: doc/conf.py
12-
13-
# Optionally set the version of Python and requirements required to build your docs
1414
conda:
15-
environment: ci/doc.yml
15+
environment: ci/doc.yml
1616

17-
python:
18-
install:
19-
- method: pip
20-
path: .
17+
formats: []

cf_xarray/accessor.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
import re
77
import warnings
88
from collections import ChainMap, namedtuple
9+
from collections.abc import Hashable, Iterable, Mapping, MutableMapping, Sequence
910
from datetime import datetime
1011
from typing import (
1112
Any,
1213
Callable,
13-
Hashable,
14-
Iterable,
15-
List,
16-
Mapping,
17-
MutableMapping,
18-
Sequence,
1914
TypeVar,
2015
Union,
2116
cast,
@@ -84,7 +79,7 @@
8479
ATTRS["vertical"] = ATTRS["Z"]
8580

8681
# Type for Mapper functions
87-
Mapper = Callable[[Union[DataArray, Dataset], Hashable], List[Hashable]]
82+
Mapper = Callable[[Union[DataArray, Dataset], Hashable], list[Hashable]]
8883

8984
# Type for decorators
9085
F = TypeVar("F", bound=Callable[..., Any])
@@ -496,7 +491,7 @@ def _get_coords(obj: DataArray | Dataset, key: Hashable) -> list[Hashable]:
496491
def _variables(func: F) -> F:
497492
@functools.wraps(func)
498493
def wrapper(obj: DataArray | Dataset, key: Hashable) -> list[DataArray]:
499-
return [obj[k] for k in func(obj, key)] # type: ignore
494+
return [obj[k] for k in func(obj, key)] # type: ignore[misc]
500495

501496
return cast(F, wrapper)
502497

@@ -1293,7 +1288,7 @@ def _process_signature(
12931288
This uses ``key_mappers``
12941289
3. Unpacks arguments if necessary before returning them.
12951290
"""
1296-
sig = inspect.signature(func, follow_wrapped=False)
1291+
sig = inspect.signature(func, follow_wrapped=True)
12971292

12981293
# Catch things like .isel(T=5).
12991294
# This assigns indexers_kwargs=dict(T=5).

cf_xarray/criteria.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
except ImportError:
1010
import re # type: ignore
1111

12-
from typing import Any, Mapping, MutableMapping, Tuple
12+
from collections.abc import Mapping, MutableMapping
13+
from typing import Any
1314

1415
_DSG_ROLES = ["timeseries_id", "profile_id", "trajectory_id"]
1516

@@ -30,7 +31,7 @@
3031
"grid_mapping": {"grid_mapping_name": re.compile(".")}
3132
}
3233

33-
coordinate_criteria: MutableMapping[str, MutableMapping[str, Tuple]] = {
34+
coordinate_criteria: MutableMapping[str, MutableMapping[str, tuple]] = {
3435
"latitude": {
3536
"standard_name": ("latitude",),
3637
"units": (

cf_xarray/formatting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import warnings
2+
from collections.abc import Hashable, Iterable
23
from functools import partial
3-
from typing import Dict, Hashable, Iterable, List
44

55
import numpy as np
66

@@ -56,7 +56,7 @@ def make_text_section(
5656
warnings.simplefilter("ignore")
5757
if isinstance(attr, str):
5858
try:
59-
vardict: Dict[str, Iterable[Hashable]] = getattr(accessor, attr, {})
59+
vardict: dict[str, Iterable[Hashable]] = getattr(accessor, attr, {})
6060
except ValueError:
6161
vardict = {}
6262
else:
@@ -103,7 +103,7 @@ def make_text_section(
103103
return _print_rows(subtitle, rows, rich)
104104

105105

106-
def _print_rows(subtitle: str, rows: List[str], rich: bool):
106+
def _print_rows(subtitle: str, rows: list[str], rich: bool):
107107
subtitle = f"{subtitle.rjust(20)}:"
108108

109109
# Add subtitle to the first row, align other rows

cf_xarray/geometry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Sequence
3+
from collections.abc import Sequence
44

55
import numpy as np
66
import pandas as pd

cf_xarray/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Hashable, Sequence
3+
from collections.abc import Hashable, Sequence
44

55
import numpy as np
66
import xarray as xr

cf_xarray/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"""
44

55
import copy
6-
from typing import Any, MutableMapping
6+
from collections.abc import MutableMapping
7+
from typing import Any
78

89
from .utils import always_iterable
910

0 commit comments

Comments
 (0)