Skip to content

Commit b1f4ab2

Browse files
committed
Render py::bool_ as bool in docstrings
1 parent 7e7c558 commit b1f4ab2

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

include/pybind11/cast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ template <typename base, typename deleter> struct is_holder_type<base, std::uniq
765765
std::true_type {};
766766

767767
template <typename T> struct handle_type_name { static constexpr auto name = const_name<T>(); };
768+
template <> struct handle_type_name<bool_> { static constexpr auto name = const_name("bool"); };
768769
template <> struct handle_type_name<bytes> { static constexpr auto name = const_name(PYBIND11_BYTES_NAME); };
769770
template <> struct handle_type_name<int_> { static constexpr auto name = const_name("int"); };
770771
template <> struct handle_type_name<iterable> { static constexpr auto name = const_name("Iterable"); };

tests/test_pytypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414

1515
TEST_SUBMODULE(pytypes, m) {
16+
// test_bool
17+
m.def("get_bool", []{return py::bool_(false);});
1618
// test_int
1719
m.def("get_int", []{return py::int_(0);});
1820
// test_iterator

tests/test_pytypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from pybind11_tests import pytypes as m
1111

1212

13+
def test_bool(doc):
14+
assert doc(m.get_bool) == "get_bool() -> bool"
15+
16+
1317
def test_int(doc):
1418
assert doc(m.get_int) == "get_int() -> int"
1519

0 commit comments

Comments
 (0)