diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 69c07bef1..b04083e2f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -889,7 +889,7 @@ struct handle_type_name { }; template <> struct handle_type_name { - static constexpr auto name = const_name("set | frozenset"); + static constexpr auto name = const_name("Union[set, frozenset]"); }; template <> struct handle_type_name { diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index cd082cdea..87d5d5518 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -121,7 +121,7 @@ def test_set(capture, doc): assert m.anyset_contains({"foo"}, "foo") assert doc(m.get_set) == "get_set() -> set" - assert doc(m.print_anyset) == "print_anyset(arg0: set | frozenset) -> None" + assert doc(m.print_anyset) == "print_anyset(arg0: Union[set, frozenset]) -> None" def test_frozenset(capture, doc):