当前位置: 首页>>代码示例>>Python>>正文


Python typing.no_type_check方法代码示例

本文整理汇总了Python中typing.no_type_check方法的典型用法代码示例。如果您正苦于以下问题:Python typing.no_type_check方法的具体用法?Python typing.no_type_check怎么用?Python typing.no_type_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typing的用法示例。


在下文中一共展示了typing.no_type_check方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_type_check

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def test_no_type_check(self):

        @no_type_check
        def foo(a: 'whatevers') -> {}:
            pass

        th = get_type_hints(foo)
        self.assertEqual(th, {}) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:10,代码来源:test_typing.py

示例2: test_no_type_check_class

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def test_no_type_check_class(self):

        @no_type_check
        class C:
            def foo(a: 'whatevers') -> {}:
                pass

        cth = get_type_hints(C.foo)
        self.assertEqual(cth, {})
        ith = get_type_hints(C().foo)
        self.assertEqual(ith, {}) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:13,代码来源:test_typing.py

示例3: test_no_type_check_no_bases

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def test_no_type_check_no_bases(self):
        class C:
            def meth(self, x: int): ...
        @no_type_check
        class D(C):
            c = C
        # verify that @no_type_check never affects bases
        self.assertEqual(get_type_hints(C.meth), {'x': int}) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:10,代码来源:test_typing.py

示例4: test_respect_no_type_check

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def test_respect_no_type_check(self):
        @no_type_check
        class NoTpCheck:
            class Inn:
                def __init__(self, x: 'not a type'): ...
        self.assertTrue(NoTpCheck.__no_type_check__)
        self.assertTrue(NoTpCheck.Inn.__init__.__no_type_check__)
        self.assertEqual(gth(ann_module2.NTC.meth), {})
        class ABase(Generic[T]):
            def meth(x: int): ...
        @no_type_check
        class Der(ABase): ...
        self.assertEqual(gth(ABase.meth), {'x': int}) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:15,代码来源:test_typing.py

示例5: no_type_check

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def no_type_check(memb):
    """Works like typing.no_type_check, but also supports cases where
    typing.no_type_check fails due to AttributeError. This can happen,
    because typing.no_type_check wants to access __no_type_check__, which
    might fail if e.g. a class is using slots or an object doesn't support
    custom attributes.
    """
    try:
        return typing.no_type_check(memb)
    except(AttributeError):
        _not_type_checked.add(memb)
        return memb 
开发者ID:Stewori,项目名称:pytypes,代码行数:14,代码来源:typechecker.py

示例6: is_no_type_check

# 需要导入模块: import typing [as 别名]
# 或者: from typing import no_type_check [as 别名]
def is_no_type_check(memb):
    """Checks if an object was annotated with @no_type_check
    (from typing or pytypes.typechecker).
    """
    try:
        return hasattr(memb, '__no_type_check__') and memb.__no_type_check__ or \
                memb in _not_type_checked
    except TypeError:
        return False 
开发者ID:Stewori,项目名称:pytypes,代码行数:11,代码来源:typechecker.py


注:本文中的typing.no_type_check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。