コード例 #1
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def callable_has_callable_type():
    assert_equal(
        "Callable[[int, str], bool]",
        format_type(types.callable_(
            [(None, types.describe(int)), (None, types.describe(str))],
            types.describe(bool)
        )),
    )
コード例 #2
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def none_is_formatted_as_none_instead_of_none_type():
    assert_equal("None", format_type(types.describe(type(None))))
コード例 #3
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def callable_ref_has_callable_type():
    assert_equal("Callable", format_type(types.callable_ref(42)))
コード例 #4
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def dict_uses_dict_class_from_pep_484():
    assert_equal("Dict[int, str]", format_type(types.Dict(types.describe(int), types.describe(str))))
コード例 #5
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def tuple_uses_tuple_class_from_pep_484():
    assert_equal("Tuple[int, str]", format_type(types.Tuple((types.describe(int), types.describe(str)))))
コード例 #6
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def iterable_uses_iterable_class_from_pep_484():
    assert_equal("Iterable[int]", format_type(types.iterable(types.describe(int))))
コード例 #7
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def list_uses_list_class_from_pep_484():
    assert_equal("List[int]", format_type(types.List(types.describe(int))))
コード例 #8
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def any_uses_any_value():
    assert_equal("Any", format_type(types.any_))
コード例 #9
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def union_uses_union_class_with_getitem():
    type_ = types.union([types.describe(type(None)), types.describe(int)])
    assert_equal("Union[None, int]", format_type(type_))
コード例 #10
0
ファイル: pep484_tests.py プロジェクト: mwilliamson/farthing
def builtin_is_formatted_as_name_of_builtin():
    assert_equal("int", format_type(types.describe(int)))