Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ 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"]
- id: ruff-format

# 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: []
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
4 changes: 2 additions & 2 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PyObject *(*) (PyObject *, PyTypeObject *)> implicit_conversions;
std::vector<std::pair<const std::type_info *, void *(*) (void *)>> implicit_casts;
std::vector<PyObject *(*)(PyObject *, PyTypeObject *)> implicit_conversions;
std::vector<std::pair<const std::type_info *, void *(*)(void *)>> implicit_casts;
std::vector<bool (*)(PyObject *, void *&)> *direct_conversions;
buffer_info *(*get_buffer)(PyObject *, void *) = nullptr;
void *get_buffer_data = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/detail/struct_smart_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ inline guarded_delete *get_guarded_delete(const std::shared_ptr<void> &ptr) {
return std::get_deleter<guarded_delete>(ptr);
}

using get_guarded_delete_fn = guarded_delete *(*) (const std::shared_ptr<void> &);
using get_guarded_delete_fn = guarded_delete *(*)(const std::shared_ptr<void> &);

template <typename T, typename std::enable_if<std::is_destructible<T>::value, int>::type = 0>
inline void std_default_delete_if_destructible(void *raw_ptr) {
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/detail/type_caster_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
35 changes: 18 additions & 17 deletions include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::int32_t, long, int, short>(NPY_LONG_, NPY_INT_, NPY_SHORT_),
NPY_INT32_ = platform_lookup<std::int32_t, long, int, short>(
NPY_LONG_, NPY_INT_, NPY_SHORT_),
NPY_UINT32_ = platform_lookup<std::uint32_t, unsigned long, unsigned int, unsigned short>(
NPY_ULONG_, NPY_UINT_, NPY_USHORT_),
NPY_INT64_
= platform_lookup<std::int64_t, long, long long, int>(NPY_LONG_, NPY_LONGLONG_, NPY_INT_),
NPY_UINT64_
= platform_lookup<std::uint64_t, unsigned long, unsigned long long, unsigned int>(
NPY_ULONG_, NPY_ULONGLONG_, NPY_UINT_),
NPY_INT64_ = platform_lookup<std::int64_t, long, long long, int>(
NPY_LONG_, NPY_LONGLONG_, NPY_INT_),
NPY_UINT64_ = platform_lookup<std::uint64_t,
unsigned long,
unsigned long long,
unsigned int>(NPY_ULONG_, NPY_ULONGLONG_, NPY_UINT_),
NPY_FLOAT32_ = platform_lookup<float, double, float, long double>(
NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_FLOAT64_ = platform_lookup<double, double, float, long double>(
NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_COMPLEX64_
= platform_lookup<std::complex<float>,
std::complex<double>,
std::complex<float>,
std::complex<long double>>(NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_COMPLEX128_
= platform_lookup<std::complex<double>,
std::complex<double>,
std::complex<float>,
std::complex<long double>>(NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_COMPLEX64_ = platform_lookup<std::complex<float>,
std::complex<double>,
std::complex<float>,
std::complex<long double>>(
NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_COMPLEX128_ = platform_lookup<std::complex<double>,
std::complex<double>,
std::complex<float>,
std::complex<long double>>(
NPY_DOUBLE_, NPY_FLOAT_, NPY_LONGDOUBLE_),
NPY_CHAR_ = std::is_signed<char>::value ? NPY_BYTE_ : NPY_UBYTE_,
};

Expand Down
3 changes: 1 addition & 2 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T,
typename = void_t<decltype(static_cast<void *(*) (size_t)>(T::operator new))>>
template <typename T, typename = void_t<decltype(static_cast<void *(*)(size_t)>(T::operator new))>>
void set_operator_new(type_record *r) {
r->operator_new = &T::operator new;
}
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/trampoline_self_life_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/pybind11_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_opaque_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_with_catch/test_args_convert_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> & vec) block
[capture](args_convert_vector &vec) block, [capture](std::vector<bool> &vec) block
// NOLINTEND(bugprone-macro-parentheses)

// For readability, rather than having ugly empty arguments.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_with_catch/test_argument_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<py::handle> & vec) block
[capture](argument_vector &vec) block, [capture](std::vector<py::handle> &vec) block
// NOLINTEND(bugprone-macro-parentheses)

// For readability, rather than having ugly empty arguments.
Expand Down
Loading