diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7ae46181..0f041f00 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,29 +3,29 @@ ci: repos: - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.4 hooks: - id: isort files: .+\.py$ - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.981 + rev: v0.991 hooks: - id: mypy additional_dependencies: [types-all] - repo: https://github.com/rstcheck/rstcheck - rev: v5.0.0 + rev: v6.1.1 hooks: - id: rstcheck additional_dependencies: [sphinx] @@ -39,7 +39,7 @@ repos: - mdformat-myst - repo: https://github.com/nbQA-dev/nbQA - rev: 1.5.2 + rev: 1.6.0 hooks: - id: nbqa-black - id: nbqa-pyupgrade @@ -52,14 +52,14 @@ repos: additional_dependencies: [mdformat==0.7.14] - repo: https://github.com/asottile/pyupgrade - rev: v2.38.2 + rev: v3.3.1 hooks: - id: pyupgrade args: - "--py37-plus" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -67,7 +67,7 @@ repos: - id: check-yaml - repo: https://github.com/keewis/blackdoc - rev: v0.3.7 + rev: v0.3.8 hooks: - id: blackdoc files: .+\.py$ diff --git a/cf_xarray/accessor.py b/cf_xarray/accessor.py index de3a4941..16ae58a7 100644 --- a/cf_xarray/accessor.py +++ b/cf_xarray/accessor.py @@ -522,7 +522,7 @@ def _getattr( accessor: CFAccessor, key_mappers: Mapping[str, Mapper], wrap_classes: bool = False, - extra_decorator: Callable = None, + extra_decorator: Callable | None = None, ): """ Common getattr functionality. @@ -613,7 +613,7 @@ def wrapper(*args, **kwargs): def _getitem( - accessor: CFAccessor, key: str | list[str], skip: list[str] = None + accessor: CFAccessor, key: str | list[str], skip: list[str] | None = None ) -> DataArray | Dataset: """ Index into obj using key. Attaches CF associated variables. @@ -1081,12 +1081,12 @@ def curvefit( self, coords: str | DataArray | Iterable[str | DataArray], func: Callable[..., Any], - reduce_dims: Hashable | Iterable[Hashable] = None, + reduce_dims: Hashable | Iterable[Hashable] | None = None, skipna: bool = True, - p0: dict[str, Any] = None, - bounds: dict[str, Any] = None, - param_names: Sequence[str] = None, - kwargs: dict[str, Any] = None, + p0: dict[str, Any] | None = None, + bounds: dict[str, Any] | None = None, + param_names: Sequence[str] | None = None, + kwargs: dict[str, Any] | None = None, ): if coords is not None: diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 56cd75e1..39a5dd47 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -1,4 +1,6 @@ -from typing import Sequence, Union +from __future__ import annotations + +from typing import Sequence import numpy as np import pandas as pd @@ -69,7 +71,7 @@ def reshape_unique_geometries( return out -def shapely_to_cf(geometries: Union[xr.DataArray, Sequence], grid_mapping: str = None): +def shapely_to_cf(geometries: xr.DataArray | Sequence, grid_mapping: str | None = None): """Convert a DataArray with shapely geometry objects into a CF-compliant dataset. .. warning:: @@ -171,7 +173,7 @@ def cf_to_shapely(ds: xr.Dataset): return geometries.rename("geometry") -def points_to_cf(pts: Union[xr.DataArray, Sequence]): +def points_to_cf(pts: xr.DataArray | Sequence): """Get a list of points (shapely.geometry.[Multi]Point) and return a CF-compliant geometry dataset. Parameters diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 0fe9fedf..5a8dc39b 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -194,7 +194,6 @@ v0.1.3 .. _`Julia Kent`: https://github.com/jukent .. _`Kristen Thyng`: https://github.com/kthyng .. _`Julius Busecke`: https://github.com/jbusecke -.. _`Filipe Fernandes`: https://github.com/ocefpaf .. _`Tom Vo`: https://github.com/tomvothecoder .. _`Romain Caneill`: https://github.com/rcaneill .. _`Lars Buntemeyer`: https://github.com/larsbuntemeyer diff --git a/setup.cfg b/setup.cfg index 16f062af..7ee57b6d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -117,7 +117,7 @@ test = pytest nobeep = True [rstcheck] -report=warning +report_level=warning ignore_roles=pr,issue,py:meth,py:attr -ignore_directives=ipython,autodata,csv-table +ignore_directives=ipython,autodata,csv-table,autosummary ignore_messages=(is not referenced\.$)