diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 678afdd..0c30d42 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] environment-file: ["environment.yaml"] defaults: run: diff --git a/pyproject.toml b/pyproject.toml index ece543f..e4a7c2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ dependencies = [ "xarray", "pystac>=1.0.1", ] -requires-python = ">=3.8" +requires-python = ">=3.10" description = "Extend xarray.open_dataset to accept pystac objects" license = {text = "MIT"} readme = "README.md" diff --git a/tests/utils.py b/tests/utils.py index 13fce99..a534ec9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,5 +1,4 @@ import importlib -from typing import Optional import pytest from packaging.version import Version @@ -7,7 +6,7 @@ # Copied from https://github.com/zarr-developers/VirtualiZarr/blob/9c3d0f90cc79fa20fe33833e244ae28a1ee91f17/virtualizarr/tests/__init__.py#L17-L34 def _importorskip( - modname: str, minversion: Optional[str] = None + modname: str, minversion: str | None = None ) -> tuple[bool, pytest.MarkDecorator]: try: mod = importlib.import_module(modname) diff --git a/xpystac/core.py b/xpystac/core.py index 8f22e2d..d01102f 100644 --- a/xpystac/core.py +++ b/xpystac/core.py @@ -1,5 +1,6 @@ import functools -from typing import List, Literal, Mapping, Union +from collections.abc import Mapping +from typing import Literal import pystac import xarray @@ -10,7 +11,7 @@ @functools.singledispatch def to_xarray( obj, - stacking_library: Union[Literal["odc.stac", "stackstac"], None] = None, + stacking_library: Literal["odc.stac", "stackstac"] | None = None, **kwargs, ) -> xarray.Dataset: """Given a PySTAC object return an xarray dataset. @@ -43,9 +44,9 @@ def to_xarray( @to_xarray.register(pystac.Item) @to_xarray.register(pystac.ItemCollection) def _( - obj: Union[pystac.Item, pystac.ItemCollection], - drop_variables: Union[str, List[str], None] = None, - stacking_library: Union[Literal["odc.stac", "stackstac"], None] = None, + obj: pystac.Item | pystac.ItemCollection, + drop_variables: str | list[str] | None = None, + stacking_library: Literal["odc.stac", "stackstac"] | None = None, **kwargs, ) -> xarray.Dataset: if drop_variables is not None: @@ -86,7 +87,7 @@ def _( @to_xarray.register def _( obj: pystac.Asset, - stacking_library: Union[Literal["odc.stac", "stackstac"], None] = None, + stacking_library: Literal["odc.stac", "stackstac"] | None = None, **kwargs, ) -> xarray.Dataset: default_kwargs: Mapping = {"chunks": {}} diff --git a/xpystac/xarray_plugin.py b/xpystac/xarray_plugin.py index 2d625c6..bad8870 100644 --- a/xpystac/xarray_plugin.py +++ b/xpystac/xarray_plugin.py @@ -1,4 +1,5 @@ -from typing import Any, Iterable, Literal, Union +from collections.abc import Iterable +from typing import Any, Literal import pystac from xarray.backends import BackendEntrypoint @@ -15,8 +16,8 @@ class STACBackend(BackendEntrypoint): def open_dataset( self, filename_or_obj: Any, - drop_variables: Union[str, Iterable[str], None] = None, - stacking_library: Union[Literal["odc.stac", "stackstac"], None] = None, + drop_variables: str | Iterable[str] | None = None, + stacking_library: Literal["odc.stac", "stackstac"] | None = None, **kwargs, ): """Given a PySTAC object return an xarray dataset