|
10 | 10 | import warnings
|
11 | 11 | from enum import Enum
|
12 | 12 | from typing import (
|
13 |
| - TYPE_CHECKING, |
14 | 13 | Any,
|
15 | 14 | Callable,
|
16 | 15 | Collection,
|
@@ -307,35 +306,18 @@ def _is_scalar(value, include_0d):
|
307 | 306 | )
|
308 | 307 |
|
309 | 308 |
|
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 |
331 | 311 | else:
|
| 312 | + from typing_extensions import TypeGuard |
332 | 313 |
|
333 |
| - def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]: |
334 |
| - """Whether to treat a value as a scalar. |
335 | 314 |
|
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) |
339 | 321 |
|
340 | 322 |
|
341 | 323 | def is_valid_numpy_dtype(dtype: Any) -> bool:
|
|
0 commit comments