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.



-- 
Steve
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/OIHDPKBSWSRV3QP2VOKP6PPA7AV65V5P/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to