
On Mon, Jan 10, 2022 at 05:39:42AM +1100, Chris Angelico wrote:
From my understanding, "x->y" would create a Callable if given two *types*, but its meaning if given two other objects is still undefined.
The PEP requires parentheses around the argument list, so that would be a SyntaxError.
The PEP also states that the arrow syntax would be equivalent to calling Callable. Callable currently enforces that the return type actually is a type, but doesn't check the input types.
(I don't know if that is a deliberate design or an oversight.)
Assuming that it is an oversight, I would expect that only the following values would be legal for the x and y objects:
- a type; - a string (which gets converted to a ForwardRef); - None;
and anything else would result in a TypeError.