Skip to content

Commit 2191fbc

Browse files
committed
another try
1 parent 8607b2e commit 2191fbc

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

doc/getting-started-guide/installing.rst

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Required dependencies
88

99
- Python (3.7 or later)
1010
- setuptools (40.4 or later)
11-
- typing-extensions (3.10 or later)
1211
- `numpy <http://www.numpy.org/>`__ (1.17 or later)
1312
- `pandas <http://pandas.pydata.org/>`__ (1.0 or later)
1413

xarray/core/utils.py

+22-14
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@
3232
import numpy as np
3333
import pandas as pd
3434

35-
try:
36-
if sys.version_info >= (3, 10):
37-
from typing import TypeGuard
38-
else:
39-
from typing_extensions import TypeGuard
40-
TypeGuardHashable = TypeGuard[Hashable]
41-
except ImportError:
42-
TypeGuardHashable = bool
43-
4435

4536
K = TypeVar("K")
4637
V = TypeVar("V")
@@ -301,11 +292,7 @@ def either_dict_or_kwargs(
301292
return pos_kwargs
302293

303294

304-
def is_scalar(value: Any, include_0d: bool = True) -> TypeGuardHashable:
305-
"""Whether to treat a value as a scalar.
306-
307-
Any non-iterable, string, or 0-D array
308-
"""
295+
def _is_scalar(value, include_0d):
309296
from .variable import NON_NUMPY_SUPPORTED_ARRAY_TYPES
310297

311298
if include_0d:
@@ -320,6 +307,27 @@ def is_scalar(value: Any, include_0d: bool = True) -> TypeGuardHashable:
320307
)
321308

322309

310+
try:
311+
if sys.version_info >= (3, 10):
312+
from typing import TypeGuard
313+
else:
314+
from typing_extensions import TypeGuard
315+
except ImportError:
316+
def is_scalar(value: Any, include_0d: bool = True) -> bool:
317+
"""Whether to treat a value as a scalar.
318+
319+
Any non-iterable, string, or 0-D array
320+
"""
321+
return _is_scalar(value, include_0d)
322+
else:
323+
def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]:
324+
"""Whether to treat a value as a scalar.
325+
326+
Any non-iterable, string, or 0-D array
327+
"""
328+
return _is_scalar(value, include_0d)
329+
330+
323331
def is_valid_numpy_dtype(dtype: Any) -> bool:
324332
try:
325333
np.dtype(dtype)

0 commit comments

Comments
 (0)