freelancing-solutions / gcp-database-as-a-service-stock-markets

GCP NDB database as a service for a stock market investment and social web services.
MIT License
3 stars 1 forks source link

support buffer protocols once #386

Open freelancing-solutions opened 3 years ago

freelancing-solutions commented 3 years ago

support buffer protocols once

https://github.com/freelancing-solutions/gcp-database-as-a-service-stock-markets/blob/62db596398a1b8786c1efd15501cac40967ef33f/venv/Lib/site-packages/numpy/typing/_array_like.py#L28


import sys
from typing import Any, overload, Sequence, TYPE_CHECKING, Union

from numpy import ndarray
from ._scalars import _ScalarLike
from ._dtype_like import DTypeLike

if sys.version_info >= (3, 8):
    from typing import Protocol
    HAVE_PROTOCOL = True
else:
    try:
        from typing_extensions import Protocol
    except ImportError:
        HAVE_PROTOCOL = False
    else:
        HAVE_PROTOCOL = True

if TYPE_CHECKING or HAVE_PROTOCOL:
    class _SupportsArray(Protocol):
        @overload
        def __array__(self, __dtype: DTypeLike = ...) -> ndarray: ...
        @overload
        def __array__(self, dtype: DTypeLike = ...) -> ndarray: ...
else:
    _SupportsArray = Any

# TODO: support buffer protocols once
#
# https://bugs.python.org/issue27501
#
# is resolved. See also the mypy issue:
#
# https://github.com/python/typing/issues/593
ArrayLike = Union[
    _ScalarLike,
    Sequence[_ScalarLike],
    Sequence[Sequence[Any]],  # TODO: Wait for support for recursive types
    _SupportsArray,
]

897b9d9bf060fa6a87efee6a5d7190369649825b