Skip to content
forked from pydata/xarray

Commit 0e4c28d

Browse files
committed
Cleanup utils.py
1 parent 2418b1e commit 0e4c28d

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

xarray/core/utils.py

+9-27
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import warnings
1111
from enum import Enum
1212
from typing import (
13-
TYPE_CHECKING,
1413
Any,
1514
Callable,
1615
Collection,
@@ -307,35 +306,18 @@ def _is_scalar(value, include_0d):
307306
)
308307

309308

310-
# See GH5624, this is a convoluted way to allow type-checking to use `TypeGuard` without
311-
# requiring typing_extensions as a required dependency to _run_ the code (it is required
312-
# to type-check).
313-
try:
314-
if sys.version_info >= (3, 10):
315-
from typing import TypeGuard
316-
else:
317-
from typing_extensions import TypeGuard
318-
except ImportError:
319-
if TYPE_CHECKING:
320-
raise
321-
else:
322-
323-
def is_scalar(value: Any, include_0d: bool = True) -> bool:
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-
309+
if sys.version_info >= (3, 10):
310+
from typing import TypeGuard
331311
else:
312+
from typing_extensions import TypeGuard
332313

333-
def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]:
334-
"""Whether to treat a value as a scalar.
335314

336-
Any non-iterable, string, or 0-D array
337-
"""
338-
return _is_scalar(value, include_0d)
315+
def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]:
316+
"""Whether to treat a value as a scalar.
317+
318+
Any non-iterable, string, or 0-D array
319+
"""
320+
return _is_scalar(value, include_0d)
339321

340322

341323
def is_valid_numpy_dtype(dtype: Any) -> bool:

0 commit comments

Comments
 (0)