[Python-ideas] Structural type checking for PEP 484

Steven D'Aprano steve at pearwood.info
Thu Sep 17 05:59:15 CEST 2015

On Wed, Sep 16, 2015 at 10:57:29PM +0200, Sven R. Kunze wrote:

> Do you know what makes me sad? If you do that for this function but 
> don't do it for another what is the guideline then? Python Zen tells us 
> to have one obvious way to do sth. At least for me, it's not obvious 
> anymore when to annotate and when not to annote. Just a random guess 
> depending on the moon phase? :(

This is no different from when to document and when to write tests.

In a perfect world, every function is fully documented and fully tested. 
But in reality we have only a limited about of time to spend writing 
code, and only a portion of that is spent writing documentation and 
tests, so we have to prioritise. Some functions are less than fully 
documented and less than fully tested. How do you decide which ones get 
your attention?

People will use the same sort of heuristic for deciding which functions 
get annotated:

- does the function need annotations/documentation/tests?
- do I have time to write annotations/documentation/tests?
- is my manager telling me to add annotations/documentation/tests?
- if I don't, will bad things happen?
- if it easy or interesting to add them?
- or difficult and boring?

Don't expect to hold annotations up to a higher standard than we already 
hold other aspects of programming.


More information about the Python-ideas mailing list