Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be6123a

Browse files
authored
Merge pull request #31426 from jorenham/backport-31425
TYP: Fix `DTypeLike` runtime type-checker support (#31425)
2 parents f880727 + a286f52 commit be6123a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

numpy/_typing/_dtype_like.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from collections.abc import Sequence # noqa: F811
2-
from typing import Any, Protocol, TypeAlias, TypedDict, TypeVar
1+
from collections.abc import Sequence
2+
from typing import Any, Protocol, TypeAlias, TypedDict, TypeVar, runtime_checkable
33

44
import numpy as np
55

@@ -41,11 +41,13 @@ class _DTypeDict(_DTypeDictBase, total=False):
4141
aligned: bool
4242

4343

44+
@runtime_checkable
4445
class _HasDType(Protocol[_DTypeT_co]):
4546
@property
4647
def dtype(self) -> _DTypeT_co: ...
4748

4849

50+
@runtime_checkable
4951
class _HasNumPyDType(Protocol[_DTypeT_co]):
5052
@property
5153
def __numpy_dtype__(self, /) -> _DTypeT_co: ...

0 commit comments

Comments
 (0)