Is `Annotated` compatible with `type[T]`?

I started this discussion by asking “Is Annotated compatible with type[T]?”. Here’s a related question: “Is Annotated callable?”

Nothing that I can find in any documentation (either in PEP 593 or in the official Python documentation) indicates that Annotated should be callable. In fact, Annotated by itself is not callable (Annotated() raises an exception), but when it is specialized (e.g. Annotated[int, ""]) an instance of the _AnnotatedAlias class is created at runtime. This object happens to be callable by virtue of subclassing from _GenericAlias. I suspect this was an unintended behavior — effectively a bug in the implementation.

When _AnnotatedAlias is called, the behavior depends on the first type argument of Annotated. If the first type argument happens to be an instantiable type form, the constructor is called, and an instance of that type is returned. For example, Annotated[tuple, ""]([1, 2, 3]) returns a tuple object.

However, many type forms are not instantiable. For example, Annotated[int | str, ""]() raises an exception.

If this is an unintended and undocumented behavior, my inclination is to file a cpython bug and suggest that this unintentional behavior be eliminated — perhaps by overriding the _AnnotatedAlias.__call__ method with a method that always raises an exception.

The challenge here is that it appears some developers have started to rely on this undocumented behavior, so it may be difficult to put the genie back in the bottle at this point.