mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Provide better type hints for a variety of generic types (#4259)
* Provide better type hints for a variety of generic types * Makes better documentation * tuple, dict, list, set, function * Move to py::typing * style: pre-commit fixes * Update copyright line with correct year and actual author. The author information was copy-pasted from the git log output. --------- Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
BSD-style license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include <pybind11/typing.h>
|
||||
|
||||
#include "pybind11_tests.h"
|
||||
|
||||
#include <utility>
|
||||
@@ -820,4 +822,12 @@ TEST_SUBMODULE(pytypes, m) {
|
||||
a >>= b;
|
||||
return a;
|
||||
});
|
||||
|
||||
m.def("annotate_tuple_float_str", [](const py::typing::Tuple<py::float_, py::str> &) {});
|
||||
m.def("annotate_tuple_empty", [](const py::typing::Tuple<> &) {});
|
||||
m.def("annotate_dict_str_int", [](const py::typing::Dict<py::str, int> &) {});
|
||||
m.def("annotate_list_int", [](const py::typing::List<int> &) {});
|
||||
m.def("annotate_set_str", [](const py::typing::Set<std::string> &) {});
|
||||
m.def("annotate_fn",
|
||||
[](const py::typing::Callable<int(py::typing::List<py::str>, py::str)> &) {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user