diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1934c2d7b4..62511523de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,14 +25,14 @@ repos: # Clang format the codebase automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v22.1.8" + rev: "v23.1.0" hooks: - id: clang-format types_or: [c++, c, cuda] # Ruff, the Python auto-correcting linter/formatter written in Rust - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.16.1 + rev: v0.16.6 hooks: - id: ruff-check args: ["--fix", "--show-fixes"] @@ -40,7 +40,7 @@ repos: # Check static types with mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v2.3.0" + rev: "v2.3.1" hooks: - id: mypy args: [] @@ -122,14 +122,14 @@ repos: # Use mirror because pre-commit autoupdate confuses tags in the upstream repo. # See https://github.com/crate-ci/typos/issues/390 - repo: https://github.com/adhtruong/mirrors-typos - rev: "v1.48.0" + rev: "v1.50.1" hooks: - id: typos args: [] # Check for common shell mistakes - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.11.0.1" + rev: "v0.11.0.1-1" hooks: - id: shellcheck @@ -144,14 +144,14 @@ repos: # PyLint has native support - not always usable, but works for us - repo: https://github.com/PyCQA/pylint - rev: "v4.0.6" + rev: "v4.0.8" hooks: - id: pylint files: ^pybind11 # Check schemas on some of our YAML files - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.37.4 + rev: 0.38.0 hooks: - id: check-readthedocs - id: check-github-workflows diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index c8fff5c144..9f8b3b3266 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -460,8 +460,8 @@ PyModuleDef_Init should be treated like any other PyObject (so not shared across try { \ pybind11::detail::ensure_internals(); \ static ::pybind11::detail::slots_array mod_def_slots \ - = ::pybind11::detail::init_slots(&PYBIND11_CONCAT(pybind11_exec_, name), \ - ##__VA_ARGS__); \ + = ::pybind11::detail::init_slots( \ + &PYBIND11_CONCAT(pybind11_exec_, name), ##__VA_ARGS__); \ static PyModuleDef def{/* m_base */ PyModuleDef_HEAD_INIT, \ /* m_name */ PYBIND11_TOSTRING(name), \ /* m_doc */ nullptr, \ diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 295485ffab..ffb6635e24 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -413,8 +413,8 @@ struct type_info { memory::get_guarded_delete_fn get_memory_guarded_delete = memory::get_guarded_delete; get_trampoline_self_life_support_fn get_trampoline_self_life_support = nullptr; - std::vector implicit_conversions; - std::vector> implicit_casts; + std::vector implicit_conversions; + std::vector> implicit_casts; std::vector *direct_conversions; buffer_info *(*get_buffer)(PyObject *, void *) = nullptr; void *get_buffer_data = nullptr; diff --git a/include/pybind11/detail/struct_smart_holder.h b/include/pybind11/detail/struct_smart_holder.h index b71981edad..57cd84310c 100644 --- a/include/pybind11/detail/struct_smart_holder.h +++ b/include/pybind11/detail/struct_smart_holder.h @@ -100,7 +100,7 @@ inline guarded_delete *get_guarded_delete(const std::shared_ptr &ptr) { return std::get_deleter(ptr); } -using get_guarded_delete_fn = guarded_delete *(*) (const std::shared_ptr &); +using get_guarded_delete_fn = guarded_delete *(*)(const std::shared_ptr &); template ::value, int>::type = 0> inline void std_default_delete_if_destructible(void *raw_ptr) { diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 161b9884fa..82bfa0b27c 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -1694,7 +1694,7 @@ class type_caster_base : public type_caster_generic { } protected: - using Constructor = void *(*) (const void *); + using Constructor = void *(*)(const void *); /* Only enabled when the types are {copy,move}-constructible *and* when the type does not have a private operator new implementation. A comma operator is used in the diff --git a/include/pybind11/embed.h b/include/pybind11/embed.h index 078f4198eb..c333892ff5 100644 --- a/include/pybind11/embed.h +++ b/include/pybind11/embed.h @@ -66,7 +66,7 @@ PYBIND11_NAMESPACE_BEGIN(detail) /// Python 2.7/3.x compatible version of `PyImport_AppendInittab` and error checks. struct embedded_module { - using init_t = PyObject *(*) (); + using init_t = PyObject *(*)(); embedded_module(const char *name, init_t init) { if (Py_IsInitialized() != 0) { pybind11_fail("Can't add new modules after the interpreter has been initialized"); diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 5b1161d8c8..a26ac2b4cd 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -244,29 +244,30 @@ struct npy_api { // `npy_common.h` defines the integer aliases. In order, it checks: // NPY_BITSOF_LONG, NPY_BITSOF_LONGLONG, NPY_BITSOF_INT, NPY_BITSOF_SHORT, NPY_BITSOF_CHAR // and assigns the alias to the first matching size, so we should check in this order. - NPY_INT32_ - = platform_lookup(NPY_LONG_, NPY_INT_, NPY_SHORT_), + NPY_INT32_ = platform_lookup( + NPY_LONG_, NPY_INT_, NPY_SHORT_), NPY_UINT32_ = platform_lookup( NPY_ULONG_, NPY_UINT_, NPY_USHORT_), - NPY_INT64_ - = platform_lookup(NPY_LONG_, NPY_LONGLONG_, NPY_INT_), - NPY_UINT64_ - = platform_lookup( - NPY_ULONG_, NPY_ULONGLONG_, NPY_UINT_), + NPY_INT64_ = platform_lookup( + NPY_LONG_, NPY_LONGLONG_, NPY_INT_), + NPY_UINT64_ = platform_lookup(NPY_ULONG_, NPY_ULONGLONG_, NPY_UINT_), NPY_FLOAT32_ = platform_lookup( NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), NPY_FLOAT64_ = platform_lookup( NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), - NPY_COMPLEX64_ - = platform_lookup, - std::complex, - std::complex, - std::complex>(NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), - NPY_COMPLEX128_ - = platform_lookup, - std::complex, - std::complex, - std::complex>(NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), + NPY_COMPLEX64_ = platform_lookup, + std::complex, + std::complex, + std::complex>( + NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), + NPY_COMPLEX128_ = platform_lookup, + std::complex, + std::complex, + std::complex>( + NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_), NPY_CHAR_ = std::is_signed::value ? NPY_BYTE_ : NPY_UBYTE_, }; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index f57514ae28..3687983460 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1932,8 +1932,7 @@ class generic_type : public object { }; /// Set the pointer to operator new if it exists. The cast is needed because it can be overloaded. -template (T::operator new))>> +template (T::operator new))>> void set_operator_new(type_record *r) { r->operator_new = &T::operator new; } diff --git a/include/pybind11/trampoline_self_life_support.h b/include/pybind11/trampoline_self_life_support.h index cbfec7f974..18bba4ade2 100644 --- a/include/pybind11/trampoline_self_life_support.h +++ b/include/pybind11/trampoline_self_life_support.h @@ -59,7 +59,7 @@ struct trampoline_self_life_support { }; PYBIND11_NAMESPACE_BEGIN(detail) -using get_trampoline_self_life_support_fn = trampoline_self_life_support *(*) (void *); +using get_trampoline_self_life_support_fn = trampoline_self_life_support *(*)(void *); PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/tests/pybind11_tests.cpp b/tests/pybind11_tests.cpp index 5dacd7aeb6..3f342a0e9c 100644 --- a/tests/pybind11_tests.cpp +++ b/tests/pybind11_tests.cpp @@ -51,7 +51,7 @@ void bind_ConstructorStats(py::module_ &m) { .def_readwrite("copy_constructions", &ConstructorStats::copy_constructions) .def_readwrite("move_constructions", &ConstructorStats::move_constructions) .def_static("get", - (ConstructorStats & (*) (py::object)) & ConstructorStats::get, + (ConstructorStats & (*)(py::object)) & ConstructorStats::get, py::return_value_policy::reference_internal) // Not exactly ConstructorStats, but related: expose the internal pybind number of diff --git a/tests/test_opaque_types.cpp b/tests/test_opaque_types.cpp index 2e972d0b88..a23e8791c2 100644 --- a/tests/test_opaque_types.cpp +++ b/tests/test_opaque_types.cpp @@ -29,7 +29,7 @@ TEST_SUBMODULE(opaque_types, m) { .def("pop_back", &StringList::pop_back) /* There are multiple versions of push_back(), etc. Select the right ones. */ .def("push_back", (void (StringList::*)(const std::string &)) &StringList::push_back) - .def("back", (std::string & (StringList::*) ()) & StringList::back) + .def("back", (std::string & (StringList::*)()) & StringList::back) .def("__len__", [](const StringList &v) { return v.size(); }) .def( "__iter__", diff --git a/tests/test_with_catch/test_args_convert_vector.cpp b/tests/test_with_catch/test_args_convert_vector.cpp index 7ce2d713fa..aa77784073 100644 --- a/tests/test_with_catch/test_args_convert_vector.cpp +++ b/tests/test_with_catch/test_args_convert_vector.cpp @@ -46,7 +46,7 @@ void mutation_test_with_samples(ActualMutationFunc actual_mutation_func, // have to work with C++11, which doesn't have generic lambdas. // NOLINTBEGIN(bugprone-macro-parentheses) #define MUTATION_LAMBDA(capture, block) \ - [capture](args_convert_vector & vec) block, [capture](std::vector & vec) block + [capture](args_convert_vector &vec) block, [capture](std::vector &vec) block // NOLINTEND(bugprone-macro-parentheses) // For readability, rather than having ugly empty arguments. diff --git a/tests/test_with_catch/test_argument_vector.cpp b/tests/test_with_catch/test_argument_vector.cpp index 9cf302a9b1..eec46487ed 100644 --- a/tests/test_with_catch/test_argument_vector.cpp +++ b/tests/test_with_catch/test_argument_vector.cpp @@ -64,7 +64,7 @@ void mutation_test_with_samples(ActualMutationFunc actual_mutation_func, // have to work with C++11, which doesn't have generic lambdas. // NOLINTBEGIN(bugprone-macro-parentheses) #define MUTATION_LAMBDA(capture, block) \ - [capture](argument_vector & vec) block, [capture](std::vector & vec) block + [capture](argument_vector &vec) block, [capture](std::vector &vec) block // NOLINTEND(bugprone-macro-parentheses) // For readability, rather than having ugly empty arguments.