Skip to content

Commit

Permalink
Merge pull request #114 from khaeru/typing/xarray-2024.1
Browse files Browse the repository at this point in the history
Adjust typing for xarray 2024.1.0
  • Loading branch information
khaeru committed Jan 22, 2024
2 parents 1b49e22 + 0a4bb8b commit ac3ba5e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -17,7 +17,7 @@ repos:
- xarray
args: []
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2
rev: v0.1.14
hooks:
- id: ruff
- id: ruff-format
Expand Down
6 changes: 3 additions & 3 deletions genno/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from hashlib import blake2b
from inspect import getmembers, iscode
from pathlib import Path
from typing import Callable, Union
from typing import Callable, Set, Union

from .util import unquote

log = logging.getLogger(__name__)

# Types to ignore in Encoder.default()
IGNORE = set()
IGNORE: Set[type] = set()


@singledispatch
Expand Down Expand Up @@ -114,7 +114,7 @@ def hash_args(*args, **kwargs):
(
""
if len(args) + len(kwargs) == 0
else json.dumps((args, kwargs), cls=Encoder)
else json.dumps((args, kwargs), cls=Encoder, sort_keys=True)
).encode(),
digest_size=20,
).hexdigest()
Expand Down
4 changes: 2 additions & 2 deletions genno/compat/plotnine/plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Hashable, Optional, Sequence
from typing import Any, Dict, Hashable, Optional, Sequence
from warnings import warn

import plotnine as p9
Expand Down Expand Up @@ -30,7 +30,7 @@ class Plot(ABC):
#: accepted by :meth:`generate`.
inputs: Sequence[Hashable] = []
#: Keyword arguments for :meth:`plotnine.ggplot.save`.
save_args = dict(verbose=False)
save_args: Dict[str, Any] = dict(verbose=False)

# TODO add static geoms automatically in generate()
__static: Sequence = []
Expand Down
2 changes: 1 addition & 1 deletion genno/core/sparsedataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(
self,
data: Any = dtypes.NA,
coords: Union[Sequence[Tuple], Mapping[Hashable, Any], None] = None,
dims: Union[Hashable, Sequence[Hashable], None] = None,
dims: Union[str, Sequence[Hashable], None] = None,
name: Hashable = None,
attrs: Optional[Mapping] = None,
# internal parameters
Expand Down
6 changes: 1 addition & 5 deletions genno/core/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from typing import Hashable, Iterable, Union

# Duplicating xarray 2022.10.0
Dims = Union[str, Iterable[Hashable], None]

from xarray.core.types import Dims

__all__ = ["Dims"]

0 comments on commit ac3ba5e

Please sign in to comment.