Author eric.snow
Recipients cool-RR, eric.snow, stutzbach
Date 2011-05-20.18:40:54
SpamBayes Score 2.09655e-11
Marked as misclassified No
Message-id <1305916855.12.0.459301693827.issue12128@psf.upfronthosting.co.za>
In-reply-to
Content
Wow!  I was literally working on this problem yesterday.  The abstract check is done at instantiation time (in object.__new__, typeobject.c).  So as it stands __new__ has no way to validate that all your abstract properties have been implemented unless they are actual properties.

The solution I found simplest is to not inherit from an ABC but rather to register your class to it, and make sure that you are compliant, whether through properties or instance names.

If there is a way to check the instance for names that "implement" abstract properties that would be a useful thing in my mind.  However, I am not sure this is doable without some serious work.  Yesterday I put together a list of some solutions that would mostly work that I plan on sending to python-list today.  I am not sure if baking that into the core of Python will work.

In my mind this is a question of if abstract methods (and thereby properties) are a promise that an instance complies with an interface or just that the class of the instance complies.
History
Date User Action Args
2011-05-20 18:40:55eric.snowsetrecipients: + eric.snow, stutzbach, cool-RR
2011-05-20 18:40:55eric.snowsetmessageid: <1305916855.12.0.459301693827.issue12128@psf.upfronthosting.co.za>
2011-05-20 18:40:54eric.snowlinkissue12128 messages
2011-05-20 18:40:54eric.snowcreate