In article <6eb91c4b-92ff-44a8-b5a9-6ef04c71f...@googlegroups.com>, rantingrickjohn...@gmail.com says... > > So if the purpose is "static analysis", what is the > justification for injecting new syntax into function sigs?
1. Annotations where created exactly for this purpose. So there's some preassure to put them to work on what they were always meant to be used for. 2. Docstrings are meant as source of code documentation and to fill the object's __doc__ attribute, as per PEP 257. As such they aren't good consistent candidates for type hinting for purposes of static analysis tools. 3. Decorators are meant as function transformation tools, as per PEP 318 and, as such, are them too not suitable to include type annotations for the purpose of static analysis. 4. There is no other formal annotation mechanism, other than these potential three. Arguably, you can make a case against 1. And that's my own issue with type hinting as it is being proposed on PEP 484. The real problem is annotations as they were defined are a really bad idea. To couple type annotations so tightly with code, just results in plain ugly and hard to read code. Personally I would love to see the present annotations just go away and a new docstring-like structure to emerge in their place. But that's probably not going to happen. What I agree can't be done though, is to use docstrings or decorators as a source for type annotations. -- https://mail.python.org/mailman/listinfo/python-list