Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 13 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@ repos:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v2.1.0"
- repo: local
hooks:
- id: mypy
additional_dependencies:
- "types-PyYAML"
- "types-requests"
- "numpy"
- id: type-check
name: type-check
entry: "pixi run --locked type-check"
# This uses local pixi installation
language: system
types:
- python
pass_filenames: false
# use require_serial so that script is only called once per commit
require_serial: true
verbose: false
always_run: false
- repo: https://github.com/adrienverge/yamllint
rev: "v1.38.0"
hooks:
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 @@ -311,7 +311,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
6 changes: 4 additions & 2 deletions esmvalcore/io/intake_esgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from esmvalcore.iris_helpers import dataset_to_iris

if TYPE_CHECKING:
from collections.abc import Mapping

import iris.cube

from esmvalcore.typing import Facets, FacetValue
Expand Down Expand Up @@ -85,7 +87,7 @@ def to_path_dict(
quiet: bool = False,
) -> dict[str, list[str | Path]]:
"""Return the current search as a dictionary of paths to files."""
kwargs = {
kwargs: Mapping[str, Any] = {
"prefer_streaming": prefer_streaming,
"globus_endpoint": globus_endpoint,
"globus_path": globus_path,
Expand Down Expand Up @@ -250,7 +252,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
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
142 changes: 142 additions & 0 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ ignore_missing_imports = true
enable_error_code = [
"truthy-bool",
]
exclude = [
"^doc/conf.py$",
"esmvalcore/cmor/tables/",
]

# Configure linters

Expand Down Expand Up @@ -296,6 +300,7 @@ test-r = { features = ["test-r"], solve-group = "test-r" }
# Other development tools.
[tool.pixi.feature.dev.dependencies]
"jupyterlab" = "*"
"mypy" = "*"
"pre-commit" = "*"
"py-spy" = "*"

Expand All @@ -314,4 +319,5 @@ test-r = { features = ["test-r"], solve-group = "test-r" }
# Tasks for use with `pixi run <task>`.
[tool.pixi.tasks]
test = {cmd = "pytest", description = "Run the tests"}
type-check = {cmd = "mypy esmvalcore", description = "Run the type checks"}
doc = {cmd = "sphinx-build doc html", description = "Build the documentation"}