Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
InvincibleRMC committed Dec 12, 2024
1 parent bae6ce2 commit e108cdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/pybind11/typing.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ struct handle_type_name<typing::Never> {
};

#if defined(PYBIND11_TYPING_H_HAS_STRING_LITERAL)
template <typing::StringLiteral StrLit>
template <auto StrLit,
typename std::enable_if<std::is_same<decltype(StrLit), typing::StringLiteral>::value,
int>::type
= 0>
auto constexpr const_name() {
return const_name(StrLit.name);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pytypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,9 @@ TEST_SUBMODULE(pytypes, m) {
.value("BLUE", literals::Color::BLUE);

m.def("annotate_complete_literal", [](literals::LiteralFoo &o) -> py::object { return o; });

m.def("literal_test", [](py::typing::Literal<"hi"> &o) -> py::object { return o; })

m.def("annotate_generic_containers",
[](const py::typing::List<typevar::TypeVarT> &l) -> py::typing::List<typevar::TypeVarV> {
return l;
Expand Down

0 comments on commit e108cdf

Please sign in to comment.