Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
41de7c1
Use mypy from pixi environment
bouweandela Jun 22, 2026
3cef218
Also use ruff from pixi env and configure dependabot for pre-commit
bouweandela Jul 16, 2026
ab7dcbc
Merge branch 'main' of github.com:ESMValGroup/ESMValCore into use-myp…
bouweandela Jul 16, 2026
f5a47e3
Remove some arguments that are not in the default pre-commit hook either
bouweandela Jul 16, 2026
33de918
Run pre-commit on CircleCI
bouweandela Jul 16, 2026
6ea1edf
Update docs
bouweandela Jul 16, 2026
639434b
Cache mypy stuff
bouweandela Jul 16, 2026
4704244
Cache mypy results in the right place
bouweandela Jul 16, 2026
1d41895
Also cache pre-commit installs
bouweandela Jul 16, 2026
31aa0d2
rerun tests
bouweandela Jul 16, 2026
0d6d7e2
Rename to pre-commit
bouweandela Jul 16, 2026
7ddaa85
Use github action instead of pre-commit hook for Zizmor checks
bouweandela Jul 16, 2026
919689f
Merge branch 'main' into use-mypy-from-pixi
bouweandela Jul 16, 2026
c5f6c85
Add mypy type stubs
bouweandela Jul 17, 2026
7ce214c
Add ruff cache to cache
bouweandela Jul 17, 2026
b4b7e93
Update lock file
bouweandela Jul 17, 2026
905b583
Fix type hints
bouweandela Jul 17, 2026
4ddf866
add pixi as dev dependency
valeriupredoi Jul 27, 2026
e571dcf
Merge branch 'main' into use-mypy-from-pixi
valeriupredoi Jul 27, 2026
c89433c
remove install of pixi since it do diddly
valeriupredoi Jul 27, 2026
f619f25
attempt to install pixi in pre-commit hook
valeriupredoi Jul 27, 2026
f77faf9
attempt to install pixi in pre-commit hook
valeriupredoi Jul 27, 2026
4f0b0e9
attempt to install pixi in pre-commit hook part deux
valeriupredoi Jul 27, 2026
578f758
try env instead of export
valeriupredoi Jul 27, 2026
43805a0
try via plain old bash -c
valeriupredoi Jul 27, 2026
e0ad767
agh forgot language
valeriupredoi Jul 27, 2026
18a2a46
use the env file
valeriupredoi Jul 27, 2026
dff5f4d
use an env file
valeriupredoi Jul 27, 2026
852045e
remove unneeded env file
valeriupredoi Jul 27, 2026
6b2f6b3
try language python with additional deps
valeriupredoi Jul 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ jobs:
- run:
name: Check dependencies are compatible
command: pixi run --as-is pip check
- run:
name: Generate pre-commit cache key
command: date '+%Y-%W' | tee pre_commit_cache_key.txt
- restore_cache:
key: pre-commit-{{ .Branch }}-{{ checksum "pre_commit_cache_key.txt" }}
- run:
name: Check code quality
command: pixi run --as-is pre-commit run -a
- save_cache:
key: pre-commit-{{ .Branch }}-{{ checksum "pre_commit_cache_key.txt" }}
paths:
- ~/.cache/pre-commit
- ./.mypy_cache
- ./.ruff_cache
- run:
name: Run tests
command: |
Expand Down
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ updates:
interval: "weekly"
cooldown:
default-days: 7
groups:
gha:
patterns:
- "*"
labels:
- dependencies
- github_actions
- automatedPR
- package-ecosystem: "pre-commit"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
groups:
pre-commit:
patterns:
- "*"
labels:
- dependencies
- github_actions
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: GitHub Actions Security Analysis with zizmor 🌈

on:
push:
branches: ["main"]
pull_request:
branches: ["**"]

permissions: {}

jobs:
zizmor:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Run zizmor 🌈
uses: zizmorcore/zizmor-action@192e21d79ab29983730a13d1382995c2307fbcaa # v0.5.7
with:
advanced-security: false
40 changes: 25 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,35 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.15.22"
- repo: local
hooks:
- id: ruff-check
args: [--fix]
name: ruff check
entry: "pixi run --locked ruff check --force-exclude --fix"
additional_dependencies: ['pixi']
language: python # system
require_serial: true
types_or:
- python
- jupyter
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v2.3.0"
hooks:
name: ruff format
entry: "pixi run --locked ruff format --force-exclude"
additional_dependencies: ['pixi']
language: python # system
require_serial: true
types_or:
- python
- jupyter
- id: mypy
additional_dependencies:
- "types-PyYAML"
- "types-requests"
- "numpy"
name: mypy
entry: "pixi run --locked mypy"
additional_dependencies: ['pixi']
language: python # system
types:
- python
pass_filenames: false
require_serial: true
- repo: https://github.com/adrienverge/yamllint
rev: "v1.38.0"
hooks:
Expand All @@ -53,8 +68,3 @@ repos:
- id: check-citation-file-format
- id: check-github-workflows
- id: check-circle-ci
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.27.0
hooks:
- id: zizmor
args: [--fix=safe]
6 changes: 3 additions & 3 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ whenever you read it.

It is recommended that you open a `draft pull
request <https://github.blog/2019-02-14-introducing-draft-pull-requests/>`__
early, as this will cause :ref:`CircleCI to run the unit tests <tests>`,
:ref:`pre-commit.ci to analyse your code <code_quality>`, and
early, as this will cause CircleCI to :ref:`run the tests <tests>` and
:ref:`analyse the code <code_quality>`, and
:ref:`readthedocs to build the documentation <documentation>`.
It's also easier to get help from other developers if your code is visible in a
pull request.
Expand Down Expand Up @@ -249,7 +249,7 @@ should be correct.
Both `ruff`_ and `mypy`_ are automatically run by pre-commit.

When you make a pull request, adherence to the Python development best practices
is checked by `pre-commit.ci <https://results.pre-commit.ci/latest/github/ESMValGroup/ESMValCore/main>`_.
is checked by running the pre-commit hooks on CircleCI.

YAML
~~~~
Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ def _run_task(
) -> tuple[list[str], set[TrackedFile]]:
"""Run task and return the result."""
if scheduler_address is None:
client = contextlib.nullcontext()
client: contextlib.AbstractContextManager = contextlib.nullcontext()
else:
client = Client(scheduler_address)

Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/cmor/_fixes/cordex/cordex_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _use_standard_lambert_conformal_grid(
lon_coord.units = "degrees_east"
lat_coord.units = "degrees_north"
lon_coord.points, lat_coord.points = transformer.transform(
*np.meshgrid(x_coord.points, y_coord.points),
*np.meshgrid(x_coord.points, y_coord.points), # type: ignore[call-overload]
errcheck=True,
)

Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/io/intake_esgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def find_data(self, **facets: FacetValue) -> list[IntakeESGFDataset]:
if not any(_isglob(v) for v in values)
}
# Translate "our" facets to ESGF facets and "our" values to ESGF values.
query = {
query: dict[str, Any] = {
their_facet: [
self.values.get(our_facet, {}).get(v, v)
for v in non_glob_facets[our_facet]
Expand Down
9 changes: 6 additions & 3 deletions esmvalcore/preprocessor/_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import shapely
import shapely.ops
import shapely.vectorized
from dask import array as da
from iris.coords import AuxCoord
from iris.cube import CubeList
Expand Down Expand Up @@ -47,6 +48,8 @@

logger = logging.getLogger(__name__)

type ExtractShapeMethod = Literal["contains", "representative"]

SHAPE_ID_KEYS: tuple[str, ...] = ("name", "NAME", "Name", "id", "ID")


Expand Down Expand Up @@ -597,7 +600,7 @@ def _get_masks_from_geometries(
geometries: dict[str, dict],
lon: np.ndarray,
lat: np.ndarray,
method: str = "contains",
method: ExtractShapeMethod = "contains",
decomposed: bool = False,
) -> dict[str, np.ndarray]:
"""Get cube masks from requested regions."""
Expand Down Expand Up @@ -643,7 +646,7 @@ def _get_bounds(
def _get_single_mask(
lon: np.ndarray,
lat: np.ndarray,
method: str,
method: ExtractShapeMethod,
geometry: dict,
) -> np.ndarray:
"""Get single mask from one region."""
Expand Down Expand Up @@ -750,7 +753,7 @@ def _update_shapefile_path(
def extract_shape(
cube: Cube,
shapefile: str | Path,
method: str = "contains",
method: ExtractShapeMethod = "contains",
crop: bool = True,
decomposed: bool = False,
ids: list | dict | None = None,
Expand Down
2 changes: 1 addition & 1 deletion esmvalcore/preprocessor/_compare_with_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def _get_emd(
arr: np.ndarray,
ref_arr: np.ndarray,
bin_centers: np.ndarray,
) -> np.ndarray:
) -> float | np.ma.core.MaskedConstant:
"""Calculate Earth mover's distance (non-lazy)."""
if np.ma.is_masked(arr) or np.ma.is_masked(ref_arr):
return np.ma.masked # this is safe because PMFs will be masked arrays
Expand Down
6 changes: 3 additions & 3 deletions esmvalcore/preprocessor/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from esmvalcore.iris_helpers import dataset_to_iris

if TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Mapping, MutableMapping, Sequence

from dask.delayed import Delayed

Expand Down Expand Up @@ -163,7 +163,7 @@ def load(
def _load_zarr(
file: str | Path,
ignore_warnings: list[dict[str, Any]] | None = None,
backend_kwargs: dict[str, Any] | None = None,
backend_kwargs: Mapping[str, Any] | None = None,
) -> CubeList:
# note on ``chunks`` kwarg to ``xr.open_dataset()``
# docs.xarray.dev/en/stable/generated/xarray.open_dataset.html
Expand All @@ -177,7 +177,7 @@ def _load_zarr(
# https://github.com/pp-mo/ncdata/issues/139

time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)
open_kwargs = {
open_kwargs: MutableMapping[str, Any] = {
"consolidated": False,
"decode_times": time_coder,
"engine": "zarr",
Expand Down
Loading