mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Render py::bool_
and py::float_
without _
in docstrings (#3622)
* Render `py::bool_` as `bool` in docstrings * Render `py::float_` as `float` in docstrings
This commit is contained in:
parent
7e7c558530
commit
5194855900
@ -765,10 +765,12 @@ template <typename base, typename deleter> struct is_holder_type<base, std::uniq
|
|||||||
std::true_type {};
|
std::true_type {};
|
||||||
|
|
||||||
template <typename T> struct handle_type_name { static constexpr auto name = const_name<T>(); };
|
template <typename T> struct handle_type_name { static constexpr auto name = const_name<T>(); };
|
||||||
|
template <> struct handle_type_name<bool_> { static constexpr auto name = const_name("bool"); };
|
||||||
template <> struct handle_type_name<bytes> { static constexpr auto name = const_name(PYBIND11_BYTES_NAME); };
|
template <> struct handle_type_name<bytes> { static constexpr auto name = const_name(PYBIND11_BYTES_NAME); };
|
||||||
template <> struct handle_type_name<int_> { static constexpr auto name = const_name("int"); };
|
template <> struct handle_type_name<int_> { static constexpr auto name = const_name("int"); };
|
||||||
template <> struct handle_type_name<iterable> { static constexpr auto name = const_name("Iterable"); };
|
template <> struct handle_type_name<iterable> { static constexpr auto name = const_name("Iterable"); };
|
||||||
template <> struct handle_type_name<iterator> { static constexpr auto name = const_name("Iterator"); };
|
template <> struct handle_type_name<iterator> { static constexpr auto name = const_name("Iterator"); };
|
||||||
|
template <> struct handle_type_name<float_> { static constexpr auto name = const_name("float"); };
|
||||||
template <> struct handle_type_name<none> { static constexpr auto name = const_name("None"); };
|
template <> struct handle_type_name<none> { static constexpr auto name = const_name("None"); };
|
||||||
template <> struct handle_type_name<args> { static constexpr auto name = const_name("*args"); };
|
template <> struct handle_type_name<args> { static constexpr auto name = const_name("*args"); };
|
||||||
template <> struct handle_type_name<kwargs> { static constexpr auto name = const_name("**kwargs"); };
|
template <> struct handle_type_name<kwargs> { static constexpr auto name = const_name("**kwargs"); };
|
||||||
|
@ -13,12 +13,16 @@
|
|||||||
|
|
||||||
|
|
||||||
TEST_SUBMODULE(pytypes, m) {
|
TEST_SUBMODULE(pytypes, m) {
|
||||||
|
// test_bool
|
||||||
|
m.def("get_bool", []{return py::bool_(false);});
|
||||||
// test_int
|
// test_int
|
||||||
m.def("get_int", []{return py::int_(0);});
|
m.def("get_int", []{return py::int_(0);});
|
||||||
// test_iterator
|
// test_iterator
|
||||||
m.def("get_iterator", []{return py::iterator();});
|
m.def("get_iterator", []{return py::iterator();});
|
||||||
// test_iterable
|
// test_iterable
|
||||||
m.def("get_iterable", []{return py::iterable();});
|
m.def("get_iterable", []{return py::iterable();});
|
||||||
|
// test_float
|
||||||
|
m.def("get_float", []{return py::float_(0.0f);});
|
||||||
// test_list
|
// test_list
|
||||||
m.def("list_no_args", []() { return py::list{}; });
|
m.def("list_no_args", []() { return py::list{}; });
|
||||||
m.def("list_ssize_t", []() { return py::list{(py::ssize_t) 0}; });
|
m.def("list_ssize_t", []() { return py::list{(py::ssize_t) 0}; });
|
||||||
|
@ -10,6 +10,10 @@ from pybind11_tests import debug_enabled
|
|||||||
from pybind11_tests import pytypes as m
|
from pybind11_tests import pytypes as m
|
||||||
|
|
||||||
|
|
||||||
|
def test_bool(doc):
|
||||||
|
assert doc(m.get_bool) == "get_bool() -> bool"
|
||||||
|
|
||||||
|
|
||||||
def test_int(doc):
|
def test_int(doc):
|
||||||
assert doc(m.get_int) == "get_int() -> int"
|
assert doc(m.get_int) == "get_int() -> int"
|
||||||
|
|
||||||
@ -22,6 +26,10 @@ def test_iterable(doc):
|
|||||||
assert doc(m.get_iterable) == "get_iterable() -> Iterable"
|
assert doc(m.get_iterable) == "get_iterable() -> Iterable"
|
||||||
|
|
||||||
|
|
||||||
|
def test_float(doc):
|
||||||
|
assert doc(m.get_float) == "get_float() -> float"
|
||||||
|
|
||||||
|
|
||||||
def test_list(capture, doc):
|
def test_list(capture, doc):
|
||||||
assert m.list_no_args() == []
|
assert m.list_no_args() == []
|
||||||
assert m.list_ssize_t() == []
|
assert m.list_ssize_t() == []
|
||||||
|
Loading…
Reference in New Issue
Block a user