How to use the typish.Literal function in typish

To help you get started, we’ve selected a few typish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ramonhagenaars / nptyping / nptyping / _ndarray_meta.py View on Github external
from collections import OrderedDict
from typing import Any, Tuple, Union

import numpy as np
from typish import SubscriptableType, Literal, ClsFunction, EllipsisType

_Size = Union[int, Literal[Any]]  # TODO add type vars as well
_Type = Union[type, Literal[Any], np.dtype]
_NSizes = Tuple[_Size, EllipsisType]
_SizeAndType = Tuple[_Size, _Type]
_Sizes = Tuple[_Size, ...]
_SizesAndType = Tuple[Tuple[_Size, ...], _Type]
_NSizesAndType = Tuple[_NSizes, _Type]
_Default = Tuple[Tuple[Literal[Any], EllipsisType], Literal[Any]]


class _NDArrayMeta(SubscriptableType):
    _shape = tuple()  # Overridden by _NDArray._shape.
    _type = ...  # Overridden by _NDArray._type.

    @property
    def dtype(cls) -> np.dtype:
        """
        Return the numpy dtype.