Skip to content

Python interpreter error with typed hints #17

Description

@DasVinch

I've grown very interested in obtaining and expanding numpy stubs.

However, when it comes to typed ndarrays, I've come to this issue

def a_function(x: np.ndarray[np.float32]) -> None:
    print('Foo')

is valid for mypy, however the python3 interpreter fails (logically. Here in interpreter, same for type hints in modules.).

In [4]: np.ndarray[np.float32]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-d3b20ca13ba6> in <module>()
----> 1 np.ndarray[np.float32]

TypeError: 'type' object is not subscriptable

Question is, how to circumvent this problem ? a typing package style protocol requiring arguments dtype, shape, etc... ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions