basic.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:properties 作者: aranzgeo 项目源码 文件源码
def error(self, instance, value, error_class=None, extra=''):
        """Generate a :code:`ValueError` for invalid value assignment

        The instance is the containing HasProperties instance, but it may
        be None if the error is raised outside a HasProperties class.
        """
        error_class = error_class if error_class is not None else ValueError
        prefix = 'The {} property'.format(self.__class__.__name__)
        if self.name != '':
            prefix = prefix + " '{}'".format(self.name)
        if instance is not None:
            prefix = prefix + ' of a {cls} instance'.format(
                cls=instance.__class__.__name__,
            )
        raise error_class(
            '{prefix} must be {info}. A value of {val!r} {vtype!r} was '
            'specified. {extra}'.format(
                prefix=prefix,
                info=self.info or 'corrected',
                val=value,
                vtype=type(value),
                extra=extra,
            )
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号