I thought since we now can forward reference types in the new parser, there is no need to stringify forward types but as you and the rest mentioned this might introduce compatibility issues with the older versions.
> On 6 Feb 2022, at 1:18 AM, Paul Bryan <pbr...@anode.ca> wrote: > > I like the idea, quite a bit. Unfortunately, string annotations are currently > reserved for type annotations (particularly for forward references), so`x: > str` and `x: "str"` are currently equivalent. This would rule-out using > string literals in the manner you suggest. > > On Sat, 2022-02-05 at 23:21 +0400, Abdulla Al Kathiri wrote: >> Hello all, >> >> Why can’t we use the literals directly as types? For example, >> >> x: Literal[1, 2, 3] = 3 >> name: Literal[“John”] | None = “John" >> >> Become …. >> >> x: 1 | 2 | 3 = 3 >> name: “John” | None = “John" >> >> >> def open(file: Path | str, mode: “w” | “a” = “w”): … >> >> Best Regards, >> >> Abdulla >> _______________________________________________ >> Python-ideas mailing list -- python-ideas@python.org >> <mailto:python-ideas@python.org> >> To unsubscribe send an email to python-ideas-le...@python.org >> <mailto:python-ideas-le...@python.org> >> https://mail.python.org/mailman3/lists/python-ideas.python.org/ >> <https://mail.python.org/mailman3/lists/python-ideas.python.org/> >> Message archived at >> https://mail.python.org/archives/list/python-ideas@python.org/message/IJ74AQRHCIIICNWYYBQTSQD2BQASRSBL/ >> >> <https://mail.python.org/archives/list/python-ideas@python.org/message/IJ74AQRHCIIICNWYYBQTSQD2BQASRSBL/> >> Code of Conduct: http://python.org/psf/codeofconduct/ >> <http://python.org/psf/codeofconduct/> >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7NN5XLW36DCAHPMASQXN3KDG7TLOFOZR/ Code of Conduct: http://python.org/psf/codeofconduct/