
May 27, 2020
3:49 p.m.
On 2020-05-26, at 13:32, kshpitsa@gmail.com wrote:
My suggestion is to introduce `typing.Auto` which, when used in return type annotation, would instruct type checker (mypy or any other) to infer return type from the type of expression in return statement. In case of multiple return statements, the pragmatical approach would probably be to infer the base-most class, possibly issuing an error or a warning if types are completely unrelated.
I like this idea. I've spent a considerable amount of time manually deducing a return type from various libraries (usually I have Mypy set to not allow missing annotations). Andrew