From 4f1531c454ada656884c6f69b56050ac9fd18b2a Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Fri, 15 May 2020 00:11:39 +0300 Subject: [PATCH] Render `py::int_` as `int` in docstrings --- include/pybind11/cast.h | 1 + tests/test_pytypes.cpp | 2 ++ tests/test_pytypes.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 5384ecafb..be4f66b06 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1606,6 +1606,7 @@ template struct is_holder_type struct handle_type_name { static constexpr auto name = _(); }; template <> struct handle_type_name { static constexpr auto name = _(PYBIND11_BYTES_NAME); }; +template <> struct handle_type_name { static constexpr auto name = _("int"); }; template <> struct handle_type_name { static constexpr auto name = _("Iterable"); }; template <> struct handle_type_name { static constexpr auto name = _("Iterator"); }; template <> struct handle_type_name { static constexpr auto name = _("*args"); }; diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index 244e1db0d..da9fcaea3 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -11,6 +11,8 @@ TEST_SUBMODULE(pytypes, m) { + // test_int + m.def("get_int", []{return py::int_(0);}); // test_list m.def("get_list", []() { py::list list; diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index 0e8d6c33a..89ec28583 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -5,6 +5,8 @@ import sys from pybind11_tests import pytypes as m from pybind11_tests import debug_enabled +def test_int(doc): + assert doc(m.get_int) == "get_int() -> int" def test_list(capture, doc): with capture: