|
63 | 63 | )
|
64 | 64 | from enum import Enum
|
65 | 65 | from pathlib import Path
|
66 |
| -from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar, overload |
| 66 | +from typing import TYPE_CHECKING, Any, Generic, Literal, TypeGuard, TypeVar, overload |
67 | 67 |
|
68 | 68 | import numpy as np
|
69 | 69 | import pandas as pd
|
@@ -275,34 +275,12 @@ def _is_scalar(value, include_0d):
|
275 | 275 | )
|
276 | 276 |
|
277 | 277 |
|
278 |
| -# See GH5624, this is a convoluted way to allow type-checking to use `TypeGuard` without |
279 |
| -# requiring typing_extensions as a required dependency to _run_ the code (it is required |
280 |
| -# to type-check). |
281 |
| -try: |
282 |
| - if sys.version_info >= (3, 10): |
283 |
| - from typing import TypeGuard |
284 |
| - else: |
285 |
| - from typing import TypeGuard |
286 |
| -except ImportError: |
287 |
| - if TYPE_CHECKING: |
288 |
| - raise |
289 |
| - else: |
290 |
| - |
291 |
| - def is_scalar(value: Any, include_0d: bool = True) -> bool: |
292 |
| - """Whether to treat a value as a scalar. |
293 |
| -
|
294 |
| - Any non-iterable, string, or 0-D array |
295 |
| - """ |
296 |
| - return _is_scalar(value, include_0d) |
| 278 | +def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]: |
| 279 | + """Whether to treat a value as a scalar. |
297 | 280 |
|
298 |
| -else: |
299 |
| - |
300 |
| - def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]: |
301 |
| - """Whether to treat a value as a scalar. |
302 |
| -
|
303 |
| - Any non-iterable, string, or 0-D array |
304 |
| - """ |
305 |
| - return _is_scalar(value, include_0d) |
| 281 | + Any non-iterable, string, or 0-D array |
| 282 | + """ |
| 283 | + return _is_scalar(value, include_0d) |
306 | 284 |
|
307 | 285 |
|
308 | 286 | def is_valid_numpy_dtype(dtype: Any) -> bool:
|
|
0 commit comments