Hello! I've got a question: Have you considered making wp.array a Generic type, rather than passing the arguments to the constructor in type annotations?
This would make the annotations "valid" (i.e. no calls inside annotations), so that type checkers could be used in the codebase.
This would make it possible to enable postponed evaluation of type annotations in the user code (https://peps.python.org/pep-0563/), which doesn't seem to be supported atm (but correct me if I'm wrong).
I assume you're using something like typing.get_type_hints or the __annotations__ dict directly in wp.kernel to extract the type annotations from the function, correct?
With a generic wp.array type, the dtype can still be easily be recovered using typing.get_args on the annotation.
Hello! I've got a question: Have you considered making
wp.array
a Generic type, rather than passing the arguments to the constructor in type annotations?For example, from this:
to this:
This would have the following benefits:
I assume you're using something like
typing.get_type_hints
or the__annotations__
dict directly inwp.kernel
to extract the type annotations from the function, correct? With a genericwp.array
type, the dtype can still be easily be recovered usingtyping.get_args
on the annotation.Let me know what you think!