It's easy to show beautiful examples that may actually depend on other
things. Whether that's representative of all contracts is another question.
I agree. There are also many contracts which are simply too hard to write down formally. But many are also easily captured in formal manner in my experience. The question is, of course, how many and you make a fair point there.
@Chris and others requesting data: my time is way too limited to provide a large-scale code analysis of many pypi packages (family obligations with a toddler, 9-6 job). I'm not doing research, and such a study would require substantial time resources. Is there an alternative request that you think that I (and other volunteers?) could accomplish in a reasonable (free) time? Maybe you could compile a list of 100-200 (or even less) functions from representative modules and I try to annotate them with contracts and we see if that's convincing? It's up to you to pick representative functions and up to me to annotate them with contracts. That would diffuse the argument that I intentionally picked the functions whose contracts are easily and nice to annotate.
On Wed, 26 Sep 2018 at 01:20, Chris Angelico email@example.com wrote:
On Wed, Sep 26, 2018 at 7:59 AM Kyle Lahnakoski firstname.lastname@example.org wrote:
I use DbC occasionally to clarify my thoughts during a refactoring, and
then only in the places that continue to make mistakes. In general, I am not in a domain that benefits from DbC.
Contracts are code: More code means more bugs.
Contracts are executable documentation. If you can lift them directly into user-readable documentation (and by "user" here I mean the user of a library), they can save you the work of keeping your documentation accurate.
This contract does not help me:
What is_absolute()? is "file:///" absolute?
I'd have to assume that is_absolute() is defined elsewhere. Which means that the value of this contract depends entirely on having other functions, probably ALSO contractually-defined, to explain it.
How does this code fail? What does a permission access problem look like?
Probably an exception. This is Python code, and I would generally assume that problems are reported as exceptions.
Can initial_paths can be None?
This can be answered from the type declaration. It doesn't say Optional, so no, it can't be None.
Can initial_paths be files? directories?
Presumably not a question you'd get if you were actually using it; the point of the function is to "[r]esolve the initial paths of the dependency graph by recursively adding *.py files beneath given directories", so you'd call it because you have directories and want files back.
What are the side effects?
Hopefully none, other than the normal implications of hitting the file system.
It's easy to show beautiful examples that may actually depend on other things. Whether that's representative of all contracts is another question.
ChrisA _______________________________________________ Python-ideas mailing list Pythonemail@example.com https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/