diff --git a/xarray/core/_reductions.py b/xarray/core/_reductions.py index 83aaa10a20c..67fbbd482d0 100644 --- a/xarray/core/_reductions.py +++ b/xarray/core/_reductions.py @@ -1,11 +1,17 @@ """Mixin classes with reduction operations.""" # This file was generated using xarray.util.generate_reductions. Do not edit manually. -from typing import Any, Callable, Hashable, Optional, Protocol, Sequence, Union +import sys +from typing import Any, Callable, Hashable, Optional, Sequence, Union from . import duck_array_ops from .types import T_DataArray, T_Dataset +if sys.version_info >= (3, 8): + from typing import Protocol +else: + from typing_extensions import Protocol + class DatasetReduce(Protocol): def reduce( diff --git a/xarray/util/generate_reductions.py b/xarray/util/generate_reductions.py index 580166e915d..72449195d1e 100644 --- a/xarray/util/generate_reductions.py +++ b/xarray/util/generate_reductions.py @@ -22,10 +22,16 @@ """Mixin classes with reduction operations.""" # This file was generated using xarray.util.generate_reductions. Do not edit manually. -from typing import Any, Callable, Hashable, Optional, Protocol, Sequence, Union +import sys +from typing import Any, Callable, Hashable, Optional, Sequence, Union from . import duck_array_ops -from .types import T_DataArray, T_Dataset''' +from .types import T_DataArray, T_Dataset + +if sys.version_info >= (3, 8): + from typing import Protocol +else: + from typing_extensions import Protocol''' OBJ_PREAMBLE = """ @@ -187,11 +193,9 @@ def generate_groupby_example(obj: str, cls: str, method: str): else: maybe_mincount = "" - return ( - f"""{create_da}{maybe_dataset} + return f"""{create_da}{maybe_dataset} >>> {calculation}(){maybe_skipna}{maybe_mincount}""" - ) def generate_method(