On Mon., 18 Nov. 2019, 6:52 am MRAB, <pyt...@mrabarnett.plus.com> wrote:

> On 2019-11-17 20:09, Ivan Levkivskyi wrote:
> > To add some more input about forward references, here are couple of
> > thoughts:
> >
> > 1. I think ideally we should support forward references to the same
> > extent they are currently supported:
> > i.e. Union[None, "ForwardRef"], Union["OtherForwardRef", None], and
> > Union["ForwardRef", "OtherForwardRef"]
> > should all be supported. The last one looks the hardest, in the sense
> > that it looks like we will need
> > to add `str.__or__()` to support these forms.
> >
> I'm not sure I like the thought of adding `str.__or__()` because it
> would mean that "Foo" | "Bar" becomes valid and returns a type, which is
> unexpected.
>
> Perhaps an alternative would be to add 'Forward' to make it explicit:
>
>      Forward("ForwardRef") | Forward("OtherForwardRef")
>
> or just:
>
>      Forward("ForwardRef") | "OtherForwardRef"
>

Or require that the entire expression be quoted in that case: "ForwardRef |
OtherForwardRef"

I wouldn't personally object to an explicit "typing.Forward" construct,
though.

Cheers,
Nick.



>
_______________________________________________
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/3HLUDMPMSJYSQ4M3TEG545MZWPDENMRG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to