From e7755651a4cf0b8682269221a0a0f293e95f2fe1 Mon Sep 17 00:00:00 2001 From: GalaxySnail Date: Thu, 14 Apr 2022 03:32:43 +0800 Subject: [PATCH] Add some tests for PEP 604 --- test/completion/pep0604.py | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/completion/pep0604.py diff --git a/test/completion/pep0604.py b/test/completion/pep0604.py new file mode 100644 index 00000000..5276251a --- /dev/null +++ b/test/completion/pep0604.py @@ -0,0 +1,46 @@ +from pep0484_generic_parameters import list_t_to_list_t + +list_of_ints_and_strs: list[int | str] + +# Test that unions are handled +x2 = list_t_to_list_t(list_of_ints_and_strs)[0] +#? int() str() +x2 + +for z in list_t_to_list_t(list_of_ints_and_strs): + #? int() str() + z + + +from pep0484_generic_passthroughs import ( + typed_variadic_tuple_generic_passthrough, +) + +variadic_tuple_str_int: tuple[int | str, ...] + +for m in typed_variadic_tuple_generic_passthrough(variadic_tuple_str_int): + #? str() int() + m + + +def func_returns_byteslike() -> bytes | bytearray: + pass + +#? bytes() bytearray() +func_returns_byteslike() + + +pep604_opetional_1: int | str | None +pep604_opetional_2: None | bytes + +#? int() str() None +pep604_opetional_1 + +#? None bytes() +pep604_opetional_2 + + +pep604_in_str: "int | bytes" + +#? int() bytes() +pep604_in_str