python类Bool()的实例源码

completer.py 文件源码 项目:leetcode 作者: thomasyimgit 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __eq__(self, other)->Bool:
        """
        Equality and hash do not hash the type (as some completer may not be
        able to infer the type), but are use to (partially) de-duplicate
        completion.

        Completely de-duplicating completion is a bit tricker that just
        comparing as it depends on surrounding text, which Completions are not
        aware of.
        """
        return self.start == other.start and \
            self.end == other.end and \
            self.text == other.text
test_jstraitlets.py 文件源码 项目:schemapi 作者: altair-viz 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_AnyOfObject():

    class Foo(jst.JSONHasTraits):
        intval = T.Integer()
        flag = T.Bool()

    class Bar(jst.JSONHasTraits):
        strval = T.Unicode()
        flag = T.Bool()

    class FooBar(jst.AnyOfObject):
        _classes = [Foo, Bar]

    FooBar(strval='hello', flag=True)
    FooBar(intval=5, flag=True)

    with pytest.raises(T.TraitError):
        FooBar(strval=666, flag=False)
    with pytest.raises(T.TraitError):
        FooBar(strval='hello', flag='bad arg')
    with pytest.raises(T.TraitError):
        FooBar(intval='bad arg', flag=False)
    with pytest.raises(T.TraitError):
        FooBar(intval=42, flag='bad arg')

    # Test from_dict
    FooBar.from_dict({'strval': 'hello', 'flag': True})
    FooBar.from_dict({'intval': 42, 'flag': False})
completer.py 文件源码 项目:yatta_reader 作者: sound88 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __eq__(self, other)->Bool:
        """
        Equality and hash do not hash the type (as some completer may not be
        able to infer the type), but are use to (partially) de-duplicate
        completion.

        Completely de-duplicating completion is a bit tricker that just
        comparing as it depends on surrounding text, which Completions are not
        aware of.
        """
        return self.start == other.start and \
            self.end == other.end and \
            self.text == other.text


问题


面经


文章

微信
公众号

扫码关注公众号