@@ -141,6 +141,16 @@ def __new__(mcls, name, bases, attrs):
141141 % (VTypeMeta .ATTRS , extra ))
142142
143143 # finally create the type
144+ # old: we remove everything from the bases
145+ # attrs['__type__'] = tuple(t for t in bases if t is not VType)
146+ # bases = (VType, )
147+ # the issue with doing this is that issubclass(PositiveInt, int) would *never* be able to work since it does
148+ # not call __subclasscheck__ on VTypeMeta but on the type of <int>.
149+ # of course we do not want to encourage users writing issubclass with VTypes, but since they are types one
150+ # day or another someone will do that ; since we have the choice let's use the less counter-intuitive
151+ # behaviour for is_subclass.
152+
153+ # new: we put everything in the bases
144154 return super (VTypeMeta , mcls ).__new__ (mcls , name , bases , attrs )
145155
146156 def __init__ (cls , # type: VTypeMeta
@@ -229,23 +239,18 @@ def __instancecheck__(cls, # type: VTypeMeta
229239 # def __subclasscheck__(cls, # type: VTypeMeta
230240 # subclass):
231241 # """
242+ # Nothing to implement here - all base types are defined as the bases of the class so the default implementation
243+ # should be ok.
232244 #
233245 # :param subclass:
234246 # :return:
235247 # """
236- # if cls is subclass: # trivial identity
237- # return True
238- # elif type(subclass) is not VTypeMeta: # subclass is not a VType
248+ # if not isinstance(subclass, VTypeMeta):
239249 # return False
240- # elif cls in subclass.__bases__: # the parent is directly one of the bases of the child
250+ # elif len(cls.__type__) > 0:
251+ # return issubclass(subclass, cls.__type__)
252+ # else:
241253 # return True
242- #
243- # # first the type should be compliant with all
244- # if not all(issubclass(subclass, parent_base) for parent_base in cls.__bases__):
245- # return False
246- #
247- # # then
248- # return len(cls.__validators__) == 0
249254
250255 def validate (cls ,
251256 name , # type: str
0 commit comments