Skip to content

Commit 5299aa7

Browse files
author
Guido Imperiale
committed
type annotations
1 parent 1d925b9 commit 5299aa7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

xarray/core/dataarray.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def _replace(
300300
self,
301301
variable: Variable = None,
302302
coords=None,
303-
name: Union[Hashable, None, ReprObject] = __default,
303+
name: Optional[Hashable] = __default,
304304
) -> 'DataArray':
305305
if variable is None:
306306
variable = self.variable
@@ -313,7 +313,7 @@ def _replace(
313313
def _replace_maybe_drop_dims(
314314
self,
315315
variable: Variable,
316-
name: Union[str, None, utils.ReprObject] = __default
316+
name: Optional[Hashable] = __default
317317
) -> 'DataArray':
318318
if variable.dims == self.dims and variable.shape == self.shape:
319319
coords = self._coords.copy()
@@ -356,7 +356,7 @@ def _to_temp_dataset(self) -> Dataset:
356356
def _from_temp_dataset(
357357
self,
358358
dataset: Dataset,
359-
name: Union[Hashable, ReprObject] = __default
359+
name: Hashable = __default
360360
) -> 'DataArray':
361361
variable = dataset._variables.pop(_THIS_ARRAY)
362362
coords = dataset._variables

xarray/tests/test_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import OrderedDict
22
from datetime import datetime
3+
from typing import Hashable
34

45
import numpy as np
56
import pandas as pd
@@ -179,6 +180,8 @@ def test_sorted_keys_dict(self):
179180
def test_repr_object():
180181
obj = utils.ReprObject('foo')
181182
assert repr(obj) == 'foo'
183+
assert isinstance(obj, Hashable)
184+
assert not isinstance(obj, str)
182185

183186

184187
def test_repr_object_magic_methods():

0 commit comments

Comments
 (0)