Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework of arg/return type hints to support .noconvert() #5486

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2a7dda2
Added rework of arg/return typing
timohl Jan 5, 2025
9d0766c
Changed `Path` to `pathlib.Path` for compatibility with pybind11-stubgen
timohl Jan 5, 2025
d9f4e1b
Removed old arg/return type hint implementation
timohl Jan 5, 2025
a86e7c4
Added noconvert support for arg/return type hints
timohl Jan 5, 2025
9877aca
Added commented failing tests for Literals with special characters
timohl Jan 5, 2025
077d0b6
Added return_descr/arg_descr for correct typing in typing::Callable
timohl Jan 5, 2025
0a677e7
Fixed clang-tidy issues
timohl Jan 9, 2025
8b3bd83
Changed io_name to have explicit return type (for C++11 support)
timohl Jan 9, 2025
8718c50
style: pre-commit fixes
pre-commit-ci[bot] Jan 9, 2025
89de7a0
Added support for nested callables
timohl Jan 9, 2025
2ba568c
Fixed missing include
timohl Jan 9, 2025
e37cd40
Fixed is_return_value constructor call
timohl Jan 9, 2025
1dd5036
Fixed clang-tidy issue
timohl Jan 9, 2025
19678a0
Uncommented test cases for special characters in literals
timohl Jan 9, 2025
1b8873b
Moved literal tests to correct test case
timohl Jan 9, 2025
e0e2225
Added escaping of special characters in typing::Literal
timohl Jan 9, 2025
b65e44b
Readded mistakenly deleted bracket
timohl Jan 9, 2025
8df42eb
Moved sanitize_string_literal to correct namespace
timohl Jan 9, 2025
9867800
Added test for Literal with `!` and changed StringLiteral template pa…
timohl Jan 9, 2025
23d9551
Added test for Literal with multiple and repeated special chars
timohl Jan 9, 2025
b577012
Simplified string literal sanitization function
timohl Jan 10, 2025
9bb4f20
Added test for `->` in literal
timohl Jan 10, 2025
e97433c
Added test for `->` with io_name
timohl Jan 10, 2025
56cab0b
Removed unused parameter name to prevent warning
timohl Jan 10, 2025
2029854
Added escaping of `-` in literal to prevent processing of `->`
timohl Jan 10, 2025
4e49c81
Fixed wrong computation of sanitized string literal length
timohl Jan 10, 2025
bbb0ca7
Added cast to prevent error with MSVC
timohl Jan 10, 2025
21f52eb
Simplified special character check
timohl Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added escaping of - in literal to prevent processing of ->
  • Loading branch information
timohl committed Jan 10, 2025
commit 2029854b03b0d2974736f778689c60b255c978dd
2 changes: 1 addition & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
@@ -500,7 +500,7 @@ class cpp_function : public function {
}
} else if (c == '!'
&& (*(pc + 1) == '!' || *(pc + 1) == '@' || *(pc + 1) == '%'
|| *(pc + 1) == '{' || *(pc + 1) == '}')) {
|| *(pc + 1) == '{' || *(pc + 1) == '}' || *(pc + 1) == '-')) {
// typing::Literal escapes special characters with !
signature += *++pc;
} else if (c == '@') {
2 changes: 1 addition & 1 deletion include/pybind11/typing.h
Original file line number Diff line number Diff line change
@@ -264,7 +264,7 @@ consteval auto sanitize_string_literal() {
+ std::ranges::count(v, '}') + 1];
size_t i = 0;
for (auto c : StrLit.name) {
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}') {
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}' || c == '-') {
result[i++] = '!';
}
result[i++] = c;
Loading