Skip to content

Commit 9877aca

Browse files
committed
Added commented failing tests for Literals with special characters
1 parent a86e7c4 commit 9877aca

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/test_pytypes.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,4 +1168,11 @@ TEST_SUBMODULE(pytypes, m) {
11681168
m.def("check_type_is", [](const py::object &x) -> py::typing::TypeIs<RealNumber> {
11691169
return py::isinstance<RealNumber>(x);
11701170
});
1171+
// Literal with `@`, `%`, `{`, and `}`
1172+
// m.def("identity_literal_x", [](const py::typing::Literal<"\"x\""> &x) { return x; });
1173+
// m.def("identity_literal_at", [](const py::typing::Literal<"\"@\""> &x) { return x; });
1174+
// m.def("identity_literal_percent", [](const py::typing::Literal<"\"%\""> &x) { return x; });
1175+
// m.def("identity_literal_curly_open", [](const py::typing::Literal<"\"{\""> &x) { return x;
1176+
// }); m.def("identity_literal_curly_close", [](const py::typing::Literal<"\"}\""> &x) { return
1177+
// x; });
11711178
}

tests/test_pytypes.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,29 @@ def test_arg_return_type_hints(doc):
12811281
)
12821282
# TypeIs<T>
12831283
assert doc(m.check_type_is) == "check_type_is(arg0: object) -> TypeIs[float]"
1284+
# Literal without special characters
1285+
# assert (
1286+
# doc(m.identity_literal_x)
1287+
# == 'identity_literal_x(arg0: Literal["x"]) -> Literal["x"]'
1288+
# )
1289+
# The Following tests fail with `ImportError: Internal error while parsing type signature (2)`
1290+
# Literal with @
1291+
# assert (
1292+
# doc(m.identity_literal_at)
1293+
# == 'identity_literal_at(arg0: Literal["@"]) -> Literal["@"]'
1294+
# )
1295+
# Literal with %
1296+
# assert (
1297+
# doc(m.identity_literal_percent)
1298+
# == 'identity_literal_percent(arg0: Literal["%"]) -> Literal["%"]'
1299+
# )
1300+
# Literal with {
1301+
# assert (
1302+
# doc(m.identity_literal_curly_open)
1303+
# == 'identity_literal_curly_open(arg0: Literal["{"]) -> Literal["{"]'
1304+
# )
1305+
# Literal with }
1306+
# assert (
1307+
# doc(m.identity_literal_curly_close)
1308+
# == 'identity_literal_curly_close(arg0: Literal["}"]) -> Literal["}"]'
1309+
# )

0 commit comments

Comments
 (0)