On Thu, 22 Apr 2021 at 21:40, Adrian Freund <m...@freundtech.com> wrote: > If I understand correctly your concerns with inferring return types for > inferred protocols are that it might be to restrictive and prevent > gradual typing. Here are some examples to show how gradual typing would > still work.
OK, I have no idea what's going on here any more. I have *no* concerns with inferring the return type. It was you who said that that inferring would be difficult - the exact quote is "You could statically type t as Union[Tuple[Literal['version'], int], Tuple[Literal['name'], str]], but inferring a Protocol for this would be either very hard or even impossible, especially with even more complex conditions." I don't know why you think I have a problem with inferring return types. All I've ever said is that I thought it might be an interesting idea if typing an argument as "DuckTyped" could result in type checkers automatically generated a suitable protocol type, based on the actual usage of the argument in the function (so that the programmer doesn't have to explicitly write and maintain a protocol class in parallel with the code). > If you have any concrete examples where inferring the return > type would break gradual typing let me know and I'll have a look at them. I don't, and I never have. As I say, it seemed to be you who was claiming that inferring would be too hard. I don't see much point in continuing this. You seem to be arguing against points I never made, or maybe I'm completely misunderstanding you. Either way, we're getting nowhere. Thanks for taking the time to try to explain, but I think all this has accomplished is to convince me that there's a "typing mindset" that embraces a level of strictness that I want nothing to do with. That's fine, we can agree to differ, but I'm a bit saddened at the thought that a certain proportion of the information available about typing might be hard for me to follow because its underlying assumptions are too different from mine. Paul _______________________________________________ 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/KADXCO56OFVLILMWWT5GDRGZERBJUQPB/ Code of Conduct: http://python.org/psf/codeofconduct/