PEP 835: Shorthand syntax for Annotated type metadata

Doesn’t it? What if I do

MY_SENTINEL @ np.array([1, 2])

?

By the way, at the moment, @ usage on numpy arrays doesn’t seem to be checked in any way by type checkers. Probably because of these overloads:

1 Like

My previous suggestion with the same idea of using @ for annotation moved the responsibility of handling matmul into the annotation object instead of attaching it to the type.

This would resolve these runtime concerns and improves backwards compatibility, at the cost of requiring libraries that use Annotated already to modify their types.

There would be a baseclass somewhere in the stdlib/typing_extension that implements __rmatmul__ (and __(r)or__)