Skip to content

How to type DTypeLike |Mapping[Any, DTypeLike] #6602

Answered by headtr1ck
headtr1ck asked this question in Q&A
Discussion options

You must be logged in to vote

I guess I will go with a custom DTypeLike definition that excludes Mappings.

This uses numpys internal definitions (many of them are still Any, but will change in future releases):

    from numpy.typing._dtype_like import _SupportsDType, _DTypeLikeNested, _ShapeLike, DType

    DTypeLikeSave = Union[
        DType[Any],
        # default data type (float64)
        None,
        # array-scalar types and generic types
        Type[Any],
        # character codes, type strings or comma-separated fields, e.g., 'float64'
        str,
        # (flexible_dtype, itemsize)
        Tuple[_DTypeLikeNested, int],
        # (fixed_dtype, shape)
        Tuple[_DTypeLikeNested, _ShapeLike],
        # …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@headtr1ck
Comment options

headtr1ck May 13, 2022
Maintainer Author

@max-sixty
Comment options

@headtr1ck
Comment options

headtr1ck May 14, 2022
Maintainer Author

@headtr1ck
Comment options

headtr1ck May 14, 2022
Maintainer Author

@max-sixty
Comment options

Comment options

headtr1ck
May 14, 2022
Maintainer Author

You must be logged in to vote
1 reply
@max-sixty
Comment options

Answer selected by headtr1ck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants