@@ -253,9 +253,9 @@ def __instancecheck__(cls, # type: VTypeMeta
253253 # return True
254254
255255 def validate (cls ,
256- name , # type: str
257- val
258- ):
256+ name , # type: str
257+ val
258+ ):
259259 """
260260 Class method that can be used to check if some value is valid. A name should be provided so that the
261261 error messages are human-friendly.
@@ -353,36 +353,8 @@ class VType(with_metaclass(VTypeMeta, object)):
353353
354354 _validator = None # type: Validator
355355
356- # @classmethod
357- # def is_vtype(cls):
358- # # type: (...) -> bool
359- # """
360- # Used by the metaclass to determine if a class is a vtype
361- # :return:
362- # """
363- # return True
364-
365356 # @classmethod
366357 # def init_vtype(cls):
367- # """
368- # Used by the metaclass to create the validator when the class is instantiated
369- # :return:
370- # """
371- # # make sure the types become a tuple
372- # # try:
373- # # cls.__type__ = tuple(cls.__type__)
374- # # except TypeError:
375- # # cls.__type__ = (cls.__type__, )
376- #
377- # cls.__type__ = classproperty()
378- #
379- # # make sure the validators become an iterable
380- # _vs = _process_validators(cls.__validators__)
381- # cls.__validators__ = _vs
382- #
383- # # create the associated validator
384- # if len(_vs) > 0:
385- # cls._validator = Validator(*_vs, help_msg=cls.__help_msg__, error_type=cls.__error_type__)
386358
387359 def __init__ (self ):
388360 raise Exception ("It does not make sense to instantiate a VType" )
@@ -392,49 +364,14 @@ def __init__(self):
392364 # name, # type: str
393365 # val
394366 # ):
395- # """
396- # Class method that can be used to check if some value is valid. A name should be provided so that the
397- # error messages are human-friendly.
398- #
399- # :param name:
400- # :param val:
401- # :return:
402- # """
403- # # validate type
404- # validate(name, val, instance_of=cls.__type__, help_msg=cls.__help_msg__, error_type=cls.__error_type__)
405- #
406- # # apply validators
407- # if cls._validator is not None:
408- # cls._validator.assert_valid(name, val, help_msg=cls.__help_msg__, error_type=cls.__error_type__)
409- #
367+
410368 # # --- boolean checks (no exception) ---
411369 #
412370 # @classmethod
413371 # def has_valid_type(cls, obj):
414- # # type: (...) -> bool
415- # """
416- #
417- # :param obj:
418- # :return:
419- # """
420- # return all(isinstance(obj, t) for t in cls.__type__)
421372 #
422373 # @classmethod
423374 # def has_valid_value(cls, obj):
424- # # type: (...) -> bool
425- # """
426- #
427- # :param obj:
428- # :return:
429- # """
430- # try:
431- # cls._validator.assert_valid('unnamed', obj)
432- # except (AttributeError, # cls._validator is None
433- # ValidationError # cls._validator is not None
434- # ):
435- # return False
436- # else:
437- # return True
438375
439376
440377# noinspection PyShadowingBuiltins
0 commit comments