Commit Graph

3007 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
e6b1370085
Copy attr comment for const char * overload, for consistency. 2024-12-20 17:30:43 -08:00
Ralf W. Grosse-Kunstleve
8f87e21291
Introduce detail::always_false<> to make the new static_assert() more readable. 2024-12-20 17:29:21 -08:00
Michael Carlstrom
4be50fe1a9 Add missing period 2024-12-20 14:26:05 -08:00
Michael Carlstrom
224189283b fixed spelling error 2024-12-20 14:25:38 -08:00
Michael Carlstrom
988c0396ff line up comment 2024-12-20 14:23:58 -08:00
pre-commit-ci[bot]
fe04344bb0 style: pre-commit fixes 2024-12-20 22:23:16 +00:00
Michael Carlstrom
1582971925 Added comment 2024-12-20 14:22:42 -08:00
Ralf W. Grosse-Kunstleve
08d477417b
Reuse const char * overload from handle overload. 2024-12-20 12:51:15 -08:00
Ralf W. Grosse-Kunstleve
cd4f771b12
Swap order of attr_with_type_hint implementation in cast.h (so that the const char * overload appears first). 2024-12-20 12:30:52 -08:00
Michael Carlstrom
a6ffbe35c4 clang tidy 2024-12-19 13:48:17 -08:00
Michael Carlstrom
f205bb4840 string wrap 2024-12-19 13:33:20 -08:00
Michael Carlstrom
8b241f1727 fix scope? 2024-12-19 13:31:09 -08:00
Michael Carlstrom
9f532cfc46 fix str namespace 2024-12-19 13:11:29 -08:00
pre-commit-ci[bot]
375ea304e8 style: pre-commit fixes 2024-12-19 21:10:53 +00:00
Michael Carlstrom
19e033c481 store reintpreted_key 2024-12-19 13:08:32 -08:00
Michael Carlstrom
7f7b70b943 add handle support to attr_with_type_hint 2024-12-19 12:57:37 -08:00
pre-commit-ci[bot]
981e0a3c83 style: pre-commit fixes 2024-12-19 01:09:58 +00:00
Michael Carlstrom
b296137950 add redeclaration test 2024-12-18 17:09:27 -08:00
Ralf W. Grosse-Kunstleve
882d20f57f
Avoid explicit false in static_assert(). 2024-12-17 13:13:34 -08:00
Ralf W. Grosse-Kunstleve
58e5a09670
Add guard: __annotations__["list_int"] was set already. 2024-12-17 13:01:50 -08:00
Ralf W. Grosse-Kunstleve
3cbaafdb8a
Test for __cpp_inline_variables and use static_assert() 2024-12-17 12:20:12 -08:00
pre-commit-ci[bot]
28d2a66350 style: pre-commit fixes 2024-12-15 21:51:35 +00:00
Michael Carlstrom
890fcae7d8 added instance check 2024-12-15 16:51:06 -05:00
Michael Carlstrom
048b539537
Merge branch 'master' into attribute-types 2024-12-15 16:03:44 -05:00
Michael Carlstrom
731745ae0f add write 2024-12-15 15:49:52 -05:00
pre-commit-ci[bot]
881b356ce8 style: pre-commit fixes 2024-12-15 20:47:11 +00:00
Michael Carlstrom
14d2dda5eb update test case 2024-12-15 15:46:10 -05:00
Ralf W. Grosse-Kunstleve
741d86f2e3
Drop Clang dev CI job (#5464)
* Drop clang dev job for now.
2024-12-12 11:15:21 -08:00
dependabot[bot]
3ebdc503d2
chore(deps): bump actions/attest-build-provenance in the actions group (#5461)
Bumps the actions group with 1 update: [actions/attest-build-provenance](https://github.com/actions/attest-build-provenance).


Updates `actions/attest-build-provenance` from 1.4.4 to 2.0.1
- [Release notes](https://github.com/actions/attest-build-provenance/releases)
- [Changelog](https://github.com/actions/attest-build-provenance/blob/main/RELEASE.md)
- [Commits](ef244123eb...c4fbc64884)

---
updated-dependencies:
- dependency-name: actions/attest-build-provenance
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-09 10:24:06 -08:00
pre-commit-ci[bot]
b17555f340
chore(deps): update pre-commit hooks (#5459)
* chore(deps): update pre-commit hooks

updates:
- [github.com/pre-commit/mirrors-clang-format: v19.1.3 → v19.1.4](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.3...v19.1.4)
- [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.8.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.8.1)
- [github.com/sirosen/texthooks: 0.6.7 → 0.6.8](https://github.com/sirosen/texthooks/compare/0.6.7...0.6.8)
- [github.com/PyCQA/pylint: v3.3.1 → v3.3.2](https://github.com/PyCQA/pylint/compare/v3.3.1...v3.3.2)
- [github.com/python-jsonschema/check-jsonschema: 0.29.4 → 0.30.0](https://github.com/python-jsonschema/check-jsonschema/compare/0.29.4...0.30.0)

* Resolve ruff pre-commit errors:

```
ruff.....................................................................Failed
- hook id: ruff
- exit code: 1

warning: The following rules have been removed and ignoring them has no effect:
    - PT004

docs/benchmark.py:51:17: UP031 Use format specifiers instead of percent format
   |
50 |     for cl in range(nclasses):
51 |         decl += "class cl%03i {\n" % cl
   |                 ^^^^^^^^^^^^^^^^^^ UP031
52 |         decl += "public:\n"
53 |         bindings += f'    py::class_<cl{cl:03}>("cl{cl:03}")\n'
   |
   = help: Replace with format specifiers

docs/benchmark.py:88:15: UP031 Use format specifiers instead of percent format
   |
86 |         elapsed = (n2 - n1).total_seconds()
87 |         size = os.stat("test.so").st_size
88 |         print("   {%i, %f, %i}," % (nclasses * nfns, elapsed, size))
   |               ^^^^^^^^^^^^^^^^^^ UP031
89 |     print("}")
   |
   = help: Replace with format specifiers

tools/make_changelog.py:62:9: PLC0206 Extracting value from dictionary without calling `.items()`
   |
61 |           msg += f"\n  `#{issue.number} <{issue.html_url}>`_"
62 |           for cat in cats:
   |  _________^
63 | |             if issue.title.lower().startswith(f"{cat}:"):
64 | |                 cats[cat].append(msg)
65 | |                 break
66 | |         else:
67 | |             cats["unknown"].append(msg)
   | |_______________________________________^ PLC0206
68 |
69 |   for cat, msgs in cats.items():
   |

Found 3 errors.

```

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2024-12-08 15:21:49 -08:00
pre-commit-ci[bot]
07f861382e style: pre-commit fixes 2024-12-08 19:36:57 +00:00
Michael Carlstrom
1571d52a18 Merge remote-tracking branch 'origin/master' into attribute-types 2024-12-08 14:36:33 -05:00
Michael Carlstrom
9160cb1af5 comments and function name cleanup 2024-12-08 14:32:59 -05:00
Tim Ohliger
1d09fc8300
Option for arg/return type hints and correct typing for std::filesystem::path (#5450)
* Added arg/return type handling.

* Added support for nested arg/return type in py::typing::List

* Added support for arg/return type in stl/filesystem

* Added tests for arg/return type in stl/filesystem and py::typing::List

* Added arg/return name to more py::typing classes

* Added arg/return type to Callable[...]

* Added tests for typing container classes (also nested)

* Changed typing classes to avoid using C++14 auto return type deduction.

* Fixed clang-tidy errors.

* Changed Enable to SFINAE

* Added test for Tuple[T, ...]

* Added RealNumber with custom caster for testing typing classes.

* Added tests for Set, Iterable, Iterator, Union, and Optional

* Added tests for Callable

* Fixed Callable with ellipsis test

* Changed TypeGuard/TypeIs to use return type (being the narrower type) + Tests

* Added test for use of fallback type name with stl vector

* Updated documentation.

* Fixed unnecessary constructor call in test.

* Fixed reference counting in example type caster.

* Fixed clang-tidy issues.

* Fix for clang-tidy

* Updated cast method to use pybind11 API rather than Python C API in custom caster example

* Updated load to use pybind11 API rather than Python C API in custom caster example

* Changed test of arg/return name to use pybind11 API instead of Python C API

* Updated code in adcanced/cast example and improved documentation text

* Fixed references in custom type caster docs

* Fixed wrong logical and operator in test

* Fixed wrong logical operator in doc example

* Added comment to test about `float` vs `float | int`

* Updated std::filesystem::path docs in cast/overview section

* Remove one stray dot.

---------

Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2024-12-08 11:30:49 -08:00
James Morris
a6d1ff2460
fix: make PYBIND11_WARNING_POP actually pop clang diagnostics (#5448)
* fix: make PYBIND11_WARNING_POP actually pop clang diagnostics

* fix: ignore -Wgnu-zero-variadic-macro-arguments on clang

* Revert "fix: ignore -Wgnu-zero-variadic-macro-arguments on clang"

This reverts commit d310959bf5.

* C++20 modernization: Use `__VA_OPT__(, ) __VA_ARGS__` in `PYBIND11_DECLARE_HOLDER_TYPE()`

* Disable `__VA_OPT__(, ) __VA_ARGS__` usage for MSVC (it is unclear to rwgk why it does not work).

This is the beginning of the error message:

```
         D:\a\pybind11\pybind11\tests\test_smart_ptr.cpp(285,1): error C2143: syntax error: missing ')' before ',' [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
         D:\a\pybind11\pybind11\tests\test_smart_ptr.cpp(285,1): error C2059: syntax error: ')' [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
```

* Add `PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")` in test_smart_ptr.cpp

This is the error message:

```
/__w/pybind11/pybind11/tests/test_smart_ptr.cpp:287:51: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
                                                  ^
/__w/pybind11/pybind11/include/pybind11/cast.h:885:13: note: macro 'PYBIND11_DECLARE_HOLDER_TYPE' defined here
            ^
```

* Also add `PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")` in test_virtual_functions.cpp

* Also add `PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")` in test_embed/test_interpreter.cpp

* Undo all changes except the original push -> pop fix.

* 1. Add `PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")` near the top of pybind11/pybind11.h; 2. Change `PYBIND11_DECLARE_HOLDER_TYPE` macro to side-step the only remaining clang warning-as-error (this is still needed even for clang 18).

Alternatively the warning suppression could be moved into pybind11/cast.h, but this commit limits the warning suppression to smaller scope within include/pybind11.

---------

Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
2024-12-08 07:16:41 -08:00
Michael Carlstrom
adfed511e2 cleanup 2024-12-05 22:20:34 -05:00
pre-commit-ci[bot]
a53bf0efc8 style: pre-commit fixes 2024-12-06 02:38:11 +00:00
Michael Carlstrom
b318d0220c add compile guard 2024-12-05 21:37:47 -05:00
pre-commit-ci[bot]
008c370ba4 style: pre-commit fixes 2024-12-06 02:06:52 +00:00
Michael Carlstrom
4a443a7adf add c++17 guard 2024-12-05 21:06:24 -05:00
Michael Carlstrom
fe21e0f8d7 try setattr 2024-12-05 20:28:09 -05:00
Michael Carlstrom
d660177409 use hasattr 2024-12-05 20:09:33 -05:00
Michael Carlstrom
e84df95bf2 add dir 2024-12-05 20:01:33 -05:00
Michael Carlstrom
4d0968dea8 use getattr 2024-12-05 19:50:22 -05:00
pre-commit-ci[bot]
31cc64f414 style: pre-commit fixes 2024-12-06 00:43:30 +00:00
Michael Carlstrom
886c9c2c80 merge 2024-12-05 19:43:06 -05:00
Michael Carlstrom
8da0ce0350 add #if 3.9 2024-12-05 19:40:10 -05:00
pre-commit-ci[bot]
639b192658 style: pre-commit fixes 2024-12-06 00:04:21 +00:00
Michael Carlstrom
e5235f00f7 test isinstance 2024-12-05 19:03:31 -05:00
Michael Carlstrom
b8ad03da76 remove stdmove 2024-12-05 16:11:24 -05:00