Commits

masklinn committed 2ab040b

Don't allow extending Base, and don't search for extends on classes we don't care for (classes which aren't Base subclasses)

Comments (0)

Files changed (2)

 
 Extends provides some tools to filter out extenders you don't need
 based on pretty arbitrary rules.
+
+Limitations of Extends
+======================
+
+Extending Base
+--------------
+
+Extends does not allow for the extension of the ``extends.Base``
+class: not only would that generate some trouble performance-wise, but
+more importantly it has too high a chance of wreaking havoc on two
+different libraries using Extends in the same project.

extends/__init__.py

 class Base(object):
     def __new__(cls):
         base_extenders = get_extends(cls)
-        ancestor_extenders = sum(map(get_extends, cls.mro()[1:]), [])
+        ancestor_extenders = sum(
+            [get_extends(ancestor) for ancestor in cls.mro()[1:]
+             if issubclass(ancestor, Base)
+             if ancestor is not Base], [])
         if not (base_extenders or ancestor_extenders):
             return object.__new__(cls)