From 8e85fadff28988f036182cc9345dae124ce7cd17 Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Sat, 27 Jun 2020 18:33:20 -0700 Subject: [PATCH 01/73] Render `py::none` as `None` in docstrings Closes #2270 --- include/pybind11/cast.h | 1 + tests/test_pytypes.cpp | 5 +++++ tests/test_pytypes.py | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index be4f66b062..28283da8f3 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1609,6 +1609,7 @@ template <> struct handle_type_name { static constexpr auto name = _(PYBI 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 = _("None"); }; template <> struct handle_type_name { static constexpr auto name = _("*args"); }; template <> struct handle_type_name { static constexpr auto name = _("**kwargs"); }; diff --git a/tests/test_pytypes.cpp b/tests/test_pytypes.cpp index e70ffae9e6..f0d86d872c 100644 --- a/tests/test_pytypes.cpp +++ b/tests/test_pytypes.cpp @@ -32,6 +32,11 @@ TEST_SUBMODULE(pytypes, m) { for (auto item : list) py::print("list item {}: {}"_s.format(index++, item)); }); + // test_none + m.def("get_none", []{return py::none();}); + m.def("print_none", [](py::none none) { + py::print("none: {}"_s.format(none)); + }); // test_set m.def("get_set", []() { diff --git a/tests/test_pytypes.py b/tests/test_pytypes.py index d6223b9ba8..79bee87750 100644 --- a/tests/test_pytypes.py +++ b/tests/test_pytypes.py @@ -37,6 +37,11 @@ def test_list(capture, doc): assert doc(m.print_list) == "print_list(arg0: list) -> None" +def test_none(capture, doc): + assert doc(m.get_none) == "get_none() -> None" + assert doc(m.print_none) == "print_none(arg0: None) -> None" + + def test_set(capture, doc): s = m.get_set() assert s == {"key1", "key2", "key3"} From a3daf87d45eb5a26c12ec44b7878f81e1dc8b8d5 Mon Sep 17 00:00:00 2001 From: fatvlady Date: Sat, 14 Mar 2020 15:15:12 +0200 Subject: [PATCH 02/73] Add failing optional test --- tests/test_stl.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ tests/test_stl.py | 10 ++++++++++ 2 files changed, 50 insertions(+) diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 207c9fb2bf..4c5ed853ab 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -50,6 +50,17 @@ namespace std { } +template