mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-13 09:46:10 +00:00
Merge branch 'master' into sh_merge_master
This commit is contained in:
@@ -46,6 +46,7 @@ main_headers = {
|
||||
"include/pybind11/stl_bind.h",
|
||||
"include/pybind11/trampoline_self_life_support.h",
|
||||
"include/pybind11/type_caster_pyobject_ptr.h",
|
||||
"include/pybind11/typing.h",
|
||||
}
|
||||
|
||||
detail_headers = {
|
||||
|
||||
@@ -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)> &) {});
|
||||
}
|
||||
|
||||
@@ -896,3 +896,38 @@ def test_inplace_lshift(a, b):
|
||||
def test_inplace_rshift(a, b):
|
||||
expected = a >> b
|
||||
assert m.inplace_rshift(a, b) == expected
|
||||
|
||||
|
||||
def test_tuple_nonempty_annotations(doc):
|
||||
assert (
|
||||
doc(m.annotate_tuple_float_str)
|
||||
== "annotate_tuple_float_str(arg0: tuple[float, str]) -> None"
|
||||
)
|
||||
|
||||
|
||||
def test_tuple_empty_annotations(doc):
|
||||
assert (
|
||||
doc(m.annotate_tuple_empty) == "annotate_tuple_empty(arg0: tuple[()]) -> None"
|
||||
)
|
||||
|
||||
|
||||
def test_dict_annotations(doc):
|
||||
assert (
|
||||
doc(m.annotate_dict_str_int)
|
||||
== "annotate_dict_str_int(arg0: dict[str, int]) -> None"
|
||||
)
|
||||
|
||||
|
||||
def test_list_annotations(doc):
|
||||
assert doc(m.annotate_list_int) == "annotate_list_int(arg0: list[int]) -> None"
|
||||
|
||||
|
||||
def test_set_annotations(doc):
|
||||
assert doc(m.annotate_set_str) == "annotate_set_str(arg0: set[str]) -> None"
|
||||
|
||||
|
||||
def test_fn_annotations(doc):
|
||||
assert (
|
||||
doc(m.annotate_fn)
|
||||
== "annotate_fn(arg0: Callable[[list[str], str], int]) -> None"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user