File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1168,4 +1168,11 @@ TEST_SUBMODULE(pytypes, m) {
1168
1168
m.def (" check_type_is" , [](const py::object &x) -> py::typing::TypeIs<RealNumber> {
1169
1169
return py::isinstance<RealNumber>(x);
1170
1170
});
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; });
1171
1178
}
Original file line number Diff line number Diff line change @@ -1281,3 +1281,29 @@ def test_arg_return_type_hints(doc):
1281
1281
)
1282
1282
# TypeIs<T>
1283
1283
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
+ # )
You can’t perform that action at this time.
0 commit comments