Marko Ristin-Kaufmann writes:

 > Do you mean annotating an abstract class with contracts or
 > annotating the actual functions in abc module?

I mean the functions in the abc module.

 > Inheriting of contracts also proved useful when you define an
 > interface as a group of functions together with the contracts. You
 > define the functions as an ABC with purely static methods (no
 > state) and specify the contracts in that abstract class.

I can envision how that would work in a situation with application-
specific classes, even in a deep hierarchy, with some discipline.
However, Python does not necessarily conform to that kind of
discipline.  I suspect that Pythonic programming styles are not
terribly amenable to inheritance of contracts.  I think the ABC module
is most likely to provide a strong evidence that I'm wrong: if
contract inheritance, and in general the contracting style of
programming, works well for that module, it will work for anything
written in Python.

By the way, I'm not asking you to do this; you've already provided
both the icontract module and a rather complete annotation of a
sizeable stdlib module.  Your work is appreciated!  Of course I'd be
happy to see a similar treatment of abc, but it's also a reasonable
candidate for thought experiments, or a sample of a few cases.

Steve


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

Reply via email to