Skip to content
forked from pydata/xarray

Commit 8106a4a

Browse files
committed
Fix typing.
1 parent fe870e5 commit 8106a4a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

xarray/core/_reductions.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
"""Mixin classes with reduction operations."""
22
# This file was generated using xarray.util.generate_reductions. Do not edit manually.
33

4-
from typing import Any, Callable, Hashable, Optional, Protocol, Sequence, Union
4+
import sys
5+
from typing import Any, Callable, Hashable, Optional, Sequence, Union
56

67
from . import duck_array_ops
78
from .types import T_DataArray, T_Dataset
89

10+
if sys.version_info >= (3, 8):
11+
from typing import Protocol
12+
else:
13+
from typing_extensions import Protocol
14+
915

1016
class DatasetReduce(Protocol):
1117
def reduce(

xarray/util/generate_reductions.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
"""Mixin classes with reduction operations."""
2323
# This file was generated using xarray.util.generate_reductions. Do not edit manually.
2424
25-
from typing import Any, Callable, Hashable, Optional, Protocol, Sequence, Union
25+
import sys
26+
from typing import Any, Callable, Hashable, Optional, Sequence, Union
2627
2728
from . import duck_array_ops
28-
from .types import T_DataArray, T_Dataset'''
29+
from .types import T_DataArray, T_Dataset
30+
31+
if sys.version_info >= (3, 8):
32+
from typing import Protocol
33+
else:
34+
from typing_extensions import Protocol'''
2935

3036
OBJ_PREAMBLE = """
3137
@@ -187,11 +193,9 @@ def generate_groupby_example(obj: str, cls: str, method: str):
187193
else:
188194
maybe_mincount = ""
189195

190-
return (
191-
f"""{create_da}{maybe_dataset}
196+
return f"""{create_da}{maybe_dataset}
192197
193198
>>> {calculation}(){maybe_skipna}{maybe_mincount}"""
194-
)
195199

196200

197201
def generate_method(

0 commit comments

Comments
 (0)