I love the proposal for dicts, but I agree that this discourages duck typing. Could the curly braces notation represent Mapping, not dict specifically?
+1 to shortening tuples but not other sequences. -- Finn Mason On Thu, Oct 14, 2021, 6:46 AM Paul Moore <p.f.mo...@gmail.com> wrote: > On Thu, 14 Oct 2021 at 13:04, Ricky Teachey <ri...@teachey.org> wrote: > > > > I think all of this additional syntax is just a mistake. > > > > The reason is it will encourage people to not properly annotate their > input types for duck typing. Some of these shortcuts might be nice for > output types. But the more general trying.Mapping, typing.Sequence and > friends should be preferred for input types. If terse shortcuts are > available for the concrete data structure types, but not for the generic > types, a lot of people are going to feel nudged to type hint their python > improperly. > > +1. I'm not sure how much of my reservations about this whole > discussion are ultimately reservations about typing in general, but I > feel that the more we make it easier to express "exact" types, the > more we encourage people to constrain their APIs to take precise types > rather than to work with duck types. (I saw an example recently where > even Mapping was over-specified, all that was needed was __getitem__, > not even __len__ or __iter__). > > I know protocols allow duck typing in a static type checking context - > maybe the energy focused on "making basic types easier to write" > should be focused on making protocols easier to write, instead. > > Paul > _______________________________________________ > 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/KALBNJN2T4HAZFK4PZUV5RGAKXAVWCMD/ > Code of Conduct: 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/C6HATFD4GXM73TDB6IMLBDIJPRVICIKI/ Code of Conduct: http://python.org/psf/codeofconduct/