Re:A Failed Experiment with Python Type Annotations
by mortoray on Tuesday June 11, 2019 @05:10PM
(#20159575)
Great!
[ Parent
| on HN ]
Re:A Failed Experiment with Python Type Annotations
by Deimorz on Tuesday June 11, 2019 @05:19PM
(#20159638)
The second issue is a bit of a judgment call too, I think. If the types were inferred you could end up with errors that you're not able to see because inferred types end up compatible. Personally, I think I'd rather write them manually so that I'm validating whether the method actually matches what it was intended to return.
I can't find a more authoritative source right now, but I also remember seeing the same thing that this SO answer says - that it was a deliberate choice not to do this so that people could incrementally add type annotations: https://stackoverflow.com/a/38775381
There are also some separate tools that can infer and generate the annotations for you. I haven't tried them personally, but the mypy docs recommends MonkeyType: https://mypy.readthedocs.io/en/stable/existing_code.html#aut...