Skip to content

ArrayLike limitations #125

Description

@OriolAbril

I am not completely sure how things have changed (if at all) between the different releases, but the current generation of type hints for ArrayLike can result is a broken type hint.

While NDArray or np.array support specifying the type with [dtype], ArrayLike does not. Attempting it results in an error:

np.typing.ArrayLike[float]
# TypeError: typing.Union[collections.abc.Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]], complex, bytes, str, numpy._typing._nested_sequence._NestedSequence[complex | bytes | str]]
# is not a generic class

The examples folder clearly shows this behaviour and IIUC test_natlang_array is testing this happens.

Note: if necessary, I will try to generate a minimal example of behaviour (or different error) through pyi files. The error above happens in the command line or when attempting to import a function with that inline hint.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions