<div dir="ltr"><div dir="ltr">Hi Chris,<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It's easy to show beautiful examples that may actually depend on other<br>
things. Whether that's representative of all contracts is another<br>
question.</blockquote><div><br></div><div>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.<br><br></div><div>@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.<br><br></div><div>Cheers,<br></div><div>Marko<br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 26 Sep 2018 at 01:20, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Sep 26, 2018 at 7:59 AM Kyle Lahnakoski <<a href="mailto:klahnakoski@mozilla.com" target="_blank">klahnakoski@mozilla.com</a>> wrote:<br>
> 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.<br>
><br>
> Contracts are code: More code means more bugs.<br>
<br>
Contracts are executable documentation. If you can lift them directly<br>
into user-readable documentation (and by "user" here I mean the user<br>
of a library), they can save you the work of keeping your<br>
documentation accurate.<br>
<br>
> This contract does not help me:<br>
><br>
> What is_absolute()?  is "file:///" absolute?<br>
<br>
I'd have to assume that is_absolute() is defined elsewhere. Which<br>
means that the value of this contract depends entirely on having other<br>
functions, probably ALSO contractually-defined, to explain it.<br>
<br>
> How does this code fail?<br>
> What does a permission access problem look like?<br>
<br>
Probably an exception. This is Python code, and I would generally<br>
assume that problems are reported as exceptions.<br>
<br>
> Can initial_paths can be None?<br>
<br>
This can be answered from the type declaration. It doesn't say<br>
Optional, so no, it can't be None.<br>
<br>
> Can initial_paths be files? directories?<br>
<br>
Presumably not a question you'd get if you were actually using it; the<br>
point of the function is to "[r]esolve the initial paths of the<br>
dependency graph by recursively adding *.py files beneath given<br>
directories", so you'd call it because you have directories and want<br>
files back.<br>
<br>
> What are the side effects?<br>
<br>
Hopefully none, other than the normal implications of hitting the file system.<br>
<br>
It's easy to show beautiful examples that may actually depend on other<br>
things. Whether that's representative of all contracts is another<br>
question.<br>
<br>
ChrisA<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>