Hi Crhis,

> In other words, you change the *public interface* of your functions
> all the time? How do you not have massive breakage all the time?

I can't comment about Marko's actual use-case, but *in general*
contracts are aimed at application *internal* interfaces, not so much
library *public* interfaces.

Sorry, I might have misunderstood the question -- I was referring to modules used within the company, not outside. Of course, public libraries put on pypi don't change their interfaces weekly.

Just to clear the confusion, both Steve and I would claim that the contracts do count as part of the interface.

For everything internal, we make changes frequently (including the interface) and more often than not, the docstring is not updated when the implementation of the function is. Contracts help our team catch breaking changes more easily. When we change the behavior of the function, we use "Find usage" in Pycharm, fix manually what we can obviously see that was affected by the changed implementation, then statically check with mypy that the changed return type did not affect the callers, and contracts (of other functions!) catch some of the bugs during testing that we missed when we changed the implementation. End-to-end test with testing contracts turned off catch some more bugs on the real data, and then it goes into production where hopefully we see no errors.

Cheers,
Marko



On Mon, 8 Oct 2018 at 12:32, Chris Angelico <rosuav@gmail.com> wrote:
On Mon, Oct 8, 2018 at 9:26 PM Steven D'Aprano <steve@pearwood.info> wrote:
> > In other words, you change the *public interface* of your functions
> > all the time? How do you not have massive breakage all the time?
>
> I can't comment about Marko's actual use-case, but *in general*
> contracts are aimed at application *internal* interfaces, not so much
> library *public* interfaces.

Yet we keep having use-cases shown to us involving one person with one
module, and another person with another module, and the interaction
between the two. Which way is it? Do the contracts change frequently
or not? Are they public or not? How are we supposed to understand the
point of contracts if the use-cases being shown all involve bad code
and/or bad coding practices?

Contracts, apparently, allow people to violate versioning expectations
and feel good about it.

(Am I really exaggerating all that much here?)

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/