Skip to content

Commit f33f6af

Browse files
chore(deps): update pre-commit hooks (#5084)
* chore(deps): update pre-commit hooks updates: - [github.com/pre-commit/mirrors-clang-format: v17.0.6 → v18.1.2](pre-commit/mirrors-clang-format@v17.0.6...v18.1.2) - [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.3.5](astral-sh/ruff-pre-commit@v0.2.0...v0.3.5) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](pre-commit/mirrors-mypy@v1.8.0...v1.9.0) - [github.com/Lucas-C/pre-commit-hooks: v1.5.4 → v1.5.5](Lucas-C/pre-commit-hooks@v1.5.4...v1.5.5) - [github.com/sirosen/texthooks: 0.6.4 → 0.6.6](sirosen/texthooks@0.6.4...0.6.6) - [github.com/shellcheck-py/shellcheck-py: v0.9.0.6 → v0.10.0.1](shellcheck-py/shellcheck-py@v0.9.0.6...v0.10.0.1) - [github.com/PyCQA/pylint: v3.0.3 → v3.1.0](pylint-dev/pylint@v3.0.3...v3.1.0) - [github.com/python-jsonschema/check-jsonschema: 0.28.0 → 0.28.1](python-jsonschema/check-jsonschema@0.28.0...0.28.1) * style: pre-commit fixes * fix(types): correction for better typing Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <[email protected]>
1 parent 7f2214b commit f33f6af

24 files changed

+106
-151
lines changed

.pre-commit-config.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ repos:
2525

2626
# Clang format the codebase automatically
2727
- repo: https://github.com/pre-commit/mirrors-clang-format
28-
rev: "v17.0.6"
28+
rev: "v18.1.2"
2929
hooks:
3030
- id: clang-format
3131
types_or: [c++, c, cuda]
3232

3333
# Ruff, the Python auto-correcting linter/formatter written in Rust
3434
- repo: https://github.com/astral-sh/ruff-pre-commit
35-
rev: v0.2.0
35+
rev: v0.3.5
3636
hooks:
3737
- id: ruff
3838
args: ["--fix", "--show-fixes"]
3939
- id: ruff-format
4040

4141
# Check static types with mypy
4242
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: "v1.8.0"
43+
rev: "v1.9.0"
4444
hooks:
4545
- id: mypy
4646
args: []
4747
exclude: ^(tests|docs)/
4848
additional_dependencies:
49-
- markdown-it-py<3 # Drop this together with dropping Python 3.7 support.
49+
- markdown-it-py
5050
- nox
5151
- rich
5252
- types-setuptools
@@ -87,13 +87,13 @@ repos:
8787

8888
# Changes tabs to spaces
8989
- repo: https://github.com/Lucas-C/pre-commit-hooks
90-
rev: "v1.5.4"
90+
rev: "v1.5.5"
9191
hooks:
9292
- id: remove-tabs
9393

9494
# Avoid directional quotes
9595
- repo: https://github.com/sirosen/texthooks
96-
rev: "0.6.4"
96+
rev: "0.6.6"
9797
hooks:
9898
- id: fix-ligatures
9999
- id: fix-smartquotes
@@ -127,7 +127,7 @@ repos:
127127

128128
# Check for common shell mistakes
129129
- repo: https://github.com/shellcheck-py/shellcheck-py
130-
rev: "v0.9.0.6"
130+
rev: "v0.10.0.1"
131131
hooks:
132132
- id: shellcheck
133133

@@ -142,13 +142,13 @@ repos:
142142

143143
# PyLint has native support - not always usable, but works for us
144144
- repo: https://github.com/PyCQA/pylint
145-
rev: "v3.0.3"
145+
rev: "v3.1.0"
146146
hooks:
147147
- id: pylint
148148
files: ^pybind11
149149

150150
- repo: https://github.com/python-jsonschema/check-jsonschema
151-
rev: 0.28.0
151+
rev: 0.28.1
152152
hooks:
153153
- id: check-readthedocs
154154
- id: check-github-workflows

include/pybind11/buffer_info.h

+14-14
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,22 @@ struct buffer_info {
102102
template <typename T>
103103
buffer_info(const T *ptr, ssize_t size, bool readonly = true)
104104
: buffer_info(
105-
const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
105+
const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
106106

107107
explicit buffer_info(Py_buffer *view, bool ownview = true)
108108
: buffer_info(
109-
view->buf,
110-
view->itemsize,
111-
view->format,
112-
view->ndim,
113-
{view->shape, view->shape + view->ndim},
114-
/* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
115-
* ignore this flag and return a view with NULL strides.
116-
* When strides are NULL, build them manually. */
117-
view->strides
118-
? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
119-
: detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
120-
(view->readonly != 0)) {
109+
view->buf,
110+
view->itemsize,
111+
view->format,
112+
view->ndim,
113+
{view->shape, view->shape + view->ndim},
114+
/* Though buffer::request() requests PyBUF_STRIDES, ctypes objects
115+
* ignore this flag and return a view with NULL strides.
116+
* When strides are NULL, build them manually. */
117+
view->strides
118+
? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
119+
: detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
120+
(view->readonly != 0)) {
121121
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
122122
this->m_view = view;
123123
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
@@ -176,7 +176,7 @@ struct buffer_info {
176176
detail::any_container<ssize_t> &&strides_in,
177177
bool readonly)
178178
: buffer_info(
179-
ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
179+
ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
180180

181181
Py_buffer *m_view = nullptr;
182182
bool ownview = false;

include/pybind11/detail/common.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,7 @@ using is_template_base_of
925925
= decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr));
926926
#else
927927
struct is_template_base_of
928-
: decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)) {
929-
};
928+
: decltype(is_template_base_of_impl<Base>::check((intrinsic_t<T> *) nullptr)){};
930929
#endif
931930

932931
/// Check if T is an instantiation of the template `Class`. For example:
@@ -1108,14 +1107,14 @@ struct overload_cast_impl {
11081107
}
11091108

11101109
template <typename Return, typename Class>
1111-
constexpr auto operator()(Return (Class::*pmf)(Args...), std::false_type = {}) const noexcept
1112-
-> decltype(pmf) {
1110+
constexpr auto operator()(Return (Class::*pmf)(Args...),
1111+
std::false_type = {}) const noexcept -> decltype(pmf) {
11131112
return pmf;
11141113
}
11151114

11161115
template <typename Return, typename Class>
1117-
constexpr auto operator()(Return (Class::*pmf)(Args...) const, std::true_type) const noexcept
1118-
-> decltype(pmf) {
1116+
constexpr auto operator()(Return (Class::*pmf)(Args...) const,
1117+
std::true_type) const noexcept -> decltype(pmf) {
11191118
return pmf;
11201119
}
11211120
};

include/pybind11/detail/descr.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ constexpr auto concat(const descr<N, Ts...> &d, const Args &...args) {
156156
}
157157
#else
158158
template <size_t N, typename... Ts, typename... Args>
159-
constexpr auto concat(const descr<N, Ts...> &d, const Args &...args)
160-
-> decltype(std::declval<descr<N + 2, Ts...>>() + concat(args...)) {
159+
constexpr auto concat(const descr<N, Ts...> &d,
160+
const Args &...args) -> decltype(std::declval<descr<N + 2, Ts...>>()
161+
+ concat(args...)) {
161162
return d + const_name(", ") + concat(args...);
162163
}
163164
#endif

include/pybind11/detail/internals.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ struct type_info {
318318

319319
#define PYBIND11_INTERNALS_ID \
320320
"__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
321-
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \
322-
PYBIND11_BUILD_TYPE "__"
321+
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
322+
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
323323

324324
#define PYBIND11_MODULE_LOCAL_ID \
325325
"__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
326-
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \
327-
PYBIND11_BUILD_TYPE "__"
326+
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
327+
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
328328

329329
/// Each module locally stores a pointer to the `internals` data. The data
330330
/// itself is shared among modules with the same `PYBIND11_INTERNALS_ID`.

include/pybind11/detail/type_caster_base.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1184,14 +1184,14 @@ class type_caster_base : public type_caster_generic {
11841184
does not have a private operator new implementation. A comma operator is used in the
11851185
decltype argument to apply SFINAE to the public copy/move constructors.*/
11861186
template <typename T, typename = enable_if_t<is_copy_constructible<T>::value>>
1187-
static auto make_copy_constructor(const T *)
1188-
-> decltype(new T(std::declval<const T>()), Constructor{}) {
1187+
static auto make_copy_constructor(const T *) -> decltype(new T(std::declval<const T>()),
1188+
Constructor{}) {
11891189
return [](const void *arg) -> void * { return new T(*reinterpret_cast<const T *>(arg)); };
11901190
}
11911191

11921192
template <typename T, typename = enable_if_t<is_move_constructible<T>::value>>
1193-
static auto make_move_constructor(const T *)
1194-
-> decltype(new T(std::declval<T &&>()), Constructor{}) {
1193+
static auto make_move_constructor(const T *) -> decltype(new T(std::declval<T &&>()),
1194+
Constructor{}) {
11951195
return [](const void *arg) -> void * {
11961196
return new T(std::move(*const_cast<T *>(reinterpret_cast<const T *>(arg))));
11971197
};

include/pybind11/stl_bind.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ void vector_modifiers(
158158
return v.release();
159159
}));
160160

161-
cl.def(
162-
"clear", [](Vector &v) { v.clear(); }, "Clear the contents");
161+
cl.def("clear", [](Vector &v) { v.clear(); }, "Clear the contents");
163162

164163
cl.def(
165164
"extend",

pybind11/setup_helpers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def no_recompile(obg: str, src: str) -> bool: # noqa: ARG001
353353
distutils.ccompiler.CCompiler,
354354
List[str],
355355
Optional[str],
356-
Optional[Union[Tuple[str], Tuple[str, Optional[str]]]],
356+
Optional[List[Union[Tuple[str], Tuple[str, Optional[str]]]]],
357357
Optional[List[str]],
358358
bool,
359359
Optional[List[str]],
@@ -429,7 +429,7 @@ def compile_function(
429429
compiler: distutils.ccompiler.CCompiler,
430430
sources: List[str],
431431
output_dir: Optional[str] = None,
432-
macros: Optional[Union[Tuple[str], Tuple[str, Optional[str]]]] = None,
432+
macros: Optional[List[Union[Tuple[str], Tuple[str, Optional[str]]]]] = None,
433433
include_dirs: Optional[List[str]] = None,
434434
debug: bool = False,
435435
extra_preargs: Optional[List[str]] = None,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ignore = [
1919

2020
[tool.mypy]
2121
files = ["pybind11"]
22-
python_version = "3.7"
22+
python_version = "3.8"
2323
strict = true
2424
show_error_codes = true
2525
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

tests/test_builtin_casters.cpp

+9-14
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ TEST_SUBMODULE(builtin_casters, m) {
9595
} // 𝐀, utf16
9696
else {
9797
wstr.push_back((wchar_t) mathbfA32);
98-
} // 𝐀, utf32
98+
} // 𝐀, utf32
9999
wstr.push_back(0x7a); // z
100100

101101
m.def("good_utf8_string", []() {
@@ -104,10 +104,9 @@ TEST_SUBMODULE(builtin_casters, m) {
104104
m.def("good_utf16_string", [=]() {
105105
return std::u16string({b16, ib16, cake16_1, cake16_2, mathbfA16_1, mathbfA16_2, z16});
106106
}); // b‽🎂𝐀z
107-
m.def("good_utf32_string", [=]() {
108-
return std::u32string({a32, mathbfA32, cake32, ib32, z32});
109-
}); // a𝐀🎂‽z
110-
m.def("good_wchar_string", [=]() { return wstr; }); // a‽𝐀z
107+
m.def("good_utf32_string",
108+
[=]() { return std::u32string({a32, mathbfA32, cake32, ib32, z32}); }); // a𝐀🎂‽z
109+
m.def("good_wchar_string", [=]() { return wstr; }); // a‽𝐀z
111110
m.def("bad_utf8_string", []() {
112111
return std::string("abc\xd0"
113112
"def");
@@ -117,9 +116,8 @@ TEST_SUBMODULE(builtin_casters, m) {
117116
// UnicodeDecodeError
118117
m.def("bad_utf32_string", [=]() { return std::u32string({a32, char32_t(0xd800), z32}); });
119118
if (sizeof(wchar_t) == 2) {
120-
m.def("bad_wchar_string", [=]() {
121-
return std::wstring({wchar_t(0x61), wchar_t(0xd800)});
122-
});
119+
m.def("bad_wchar_string",
120+
[=]() { return std::wstring({wchar_t(0x61), wchar_t(0xd800)}); });
123121
}
124122
m.def("u8_Z", []() -> char { return 'Z'; });
125123
m.def("u8_eacute", []() -> char { return '\xe9'; });
@@ -236,8 +234,7 @@ TEST_SUBMODULE(builtin_casters, m) {
236234

237235
// test_int_convert
238236
m.def("int_passthrough", [](int arg) { return arg; });
239-
m.def(
240-
"int_passthrough_noconvert", [](int arg) { return arg; }, py::arg{}.noconvert());
237+
m.def("int_passthrough_noconvert", [](int arg) { return arg; }, py::arg{}.noconvert());
241238

242239
// test_tuple
243240
m.def(
@@ -302,17 +299,15 @@ TEST_SUBMODULE(builtin_casters, m) {
302299

303300
// test_bool_caster
304301
m.def("bool_passthrough", [](bool arg) { return arg; });
305-
m.def(
306-
"bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg{}.noconvert());
302+
m.def("bool_passthrough_noconvert", [](bool arg) { return arg; }, py::arg{}.noconvert());
307303

308304
// TODO: This should be disabled and fixed in future Intel compilers
309305
#if !defined(__INTEL_COMPILER)
310306
// Test "bool_passthrough_noconvert" again, but using () instead of {} to construct py::arg
311307
// When compiled with the Intel compiler, this results in segmentation faults when importing
312308
// the module. Tested with icc (ICC) 2021.1 Beta 20200827, this should be tested again when
313309
// a newer version of icc is available.
314-
m.def(
315-
"bool_passthrough_noconvert2", [](bool arg) { return arg; }, py::arg().noconvert());
310+
m.def("bool_passthrough_noconvert2", [](bool arg) { return arg; }, py::arg().noconvert());
316311
#endif
317312

318313
// test_reference_wrapper

tests/test_call_policies.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ TEST_SUBMODULE(call_policies, m) {
6363
.def("returnNullChildKeepAliveParent", &Parent::returnNullChild, py::keep_alive<0, 1>())
6464
.def_static("staticFunction", &Parent::staticFunction, py::keep_alive<1, 0>());
6565

66-
m.def(
67-
"free_function", [](Parent *, Child *) {}, py::keep_alive<1, 2>());
68-
m.def(
69-
"invalid_arg_index", [] {}, py::keep_alive<0, 1>());
66+
m.def("free_function", [](Parent *, Child *) {}, py::keep_alive<1, 2>());
67+
m.def("invalid_arg_index", [] {}, py::keep_alive<0, 1>());
7068

7169
#if !defined(PYPY_VERSION)
7270
// test_alive_gc

tests/test_class.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ TEST_SUBMODULE(class_, m) {
461461
py::class_<Nested>(base, "Nested")
462462
.def(py::init<>())
463463
.def("fn", [](Nested &, int, NestBase &, Nested &) {})
464-
.def(
465-
"fa", [](Nested &, int, NestBase &, Nested &) {}, "a"_a, "b"_a, "c"_a);
464+
.def("fa", [](Nested &, int, NestBase &, Nested &) {}, "a"_a, "b"_a, "c"_a);
466465
base.def("g", [](NestBase &, Nested &) {});
467466
base.def("h", []() { return NestBase(); });
468467

tests/test_copy_move.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ TEST_SUBMODULE(copy_move_policies, m) {
289289
"get_moveissue1",
290290
[](int i) { return std::unique_ptr<MoveIssue1>(new MoveIssue1(i)); },
291291
py::return_value_policy::move);
292-
m.def(
293-
"get_moveissue2", [](int i) { return MoveIssue2(i); }, py::return_value_policy::move);
292+
m.def("get_moveissue2", [](int i) { return MoveIssue2(i); }, py::return_value_policy::move);
294293

295294
// Make sure that cast from pytype rvalue to other pytype works
296295
m.def("get_pytype_rvalue_castissue", [](double i) { return py::float_(i).cast<py::int_>(); });

tests/test_custom_type_casters.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,10 @@ TEST_SUBMODULE(custom_type_casters, m) {
185185
py::arg_v(nullptr, ArgInspector1()).noconvert(true),
186186
py::arg() = ArgAlwaysConverts());
187187

188-
m.def(
189-
"floats_preferred", [](double f) { return 0.5 * f; }, "f"_a);
190-
m.def(
191-
"floats_only", [](double f) { return 0.5 * f; }, "f"_a.noconvert());
192-
m.def(
193-
"ints_preferred", [](int i) { return i / 2; }, "i"_a);
194-
m.def(
195-
"ints_only", [](int i) { return i / 2; }, "i"_a.noconvert());
188+
m.def("floats_preferred", [](double f) { return 0.5 * f; }, "f"_a);
189+
m.def("floats_only", [](double f) { return 0.5 * f; }, "f"_a.noconvert());
190+
m.def("ints_preferred", [](int i) { return i / 2; }, "i"_a);
191+
m.def("ints_only", [](int i) { return i / 2; }, "i"_a.noconvert());
196192

197193
// test_custom_caster_destruction
198194
// Test that `take_ownership` works on types with a custom type caster when given a pointer

0 commit comments

Comments
 (0)