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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ repos:

# Clang format the codebase automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v21.1.8"
rev: "v22.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.14.14
rev: v0.15.4
hooks:
- id: ruff-check
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -122,7 +122,7 @@ 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.42.3"
rev: "v1.44.0"
hooks:
- id: typos
args: []
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.4"
rev: "v4.0.5"
hooks:
- id: pylint
files: ^pybind11

# Check schemas on some of our YAML files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.36.1
rev: 0.37.0
hooks:
- id: check-readthedocs
- id: check-github-workflows
Expand Down
12 changes: 4 additions & 8 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ public:
template <typename T_, \
::pybind11::detail::enable_if_t< \
std::is_same<type, ::pybind11::detail::remove_cv_t<T_>>::value, \
int> \
= 0> \
int> = 0> \
static ::pybind11::handle cast( \
T_ *src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { \
if (!src) \
Expand Down Expand Up @@ -1663,8 +1662,7 @@ PYBIND11_NAMESPACE_END(detail)
template <typename T,
detail::enable_if_t<!detail::is_pyobject<T>::value
&& !detail::is_same_ignoring_cvref<T, PyObject *>::value,
int>
= 0>
int> = 0>
T cast(const handle &handle) {
using namespace detail;
constexpr bool is_enum_cast = type_uses_type_caster_enum_type<intrinsic_t<T>>::value;
Expand Down Expand Up @@ -1699,8 +1697,7 @@ template <typename T,
typename Handle,
detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::value
&& detail::is_same_ignoring_cvref<Handle, handle>::value,
int>
= 0>
int> = 0>
T cast(Handle &&handle) {
return handle.inc_ref().ptr();
}
Expand All @@ -1709,8 +1706,7 @@ template <typename T,
typename Object,
detail::enable_if_t<detail::is_same_ignoring_cvref<T, PyObject *>::value
&& detail::is_same_ignoring_cvref<Object, object>::value,
int>
= 0>
int> = 0>
T cast(Object &&obj) {
return obj.release().ptr();
}
Expand Down
3 changes: 1 addition & 2 deletions include/pybind11/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ class duration_caster {
return src;
}
static const std::chrono::duration<rep, period> &
get_duration(const std::chrono::duration<rep, period> &&)
= delete;
get_duration(const std::chrono::duration<rep, period> &&) = delete;

// If this is a time_point get the time_since_epoch
template <typename Clock>
Expand Down
27 changes: 12 additions & 15 deletions include/pybind11/detail/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,10 @@ struct constructor {
extra...);
}

template <
typename Class,
typename... Extra,
enable_if_t<Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value, int>
= 0>
template <typename Class,
typename... Extra,
enable_if_t<Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value,
int> = 0>
static void execute(Class &cl, const Extra &...extra) {
cl.def(
"__init__",
Expand All @@ -325,11 +324,10 @@ struct constructor {
extra...);
}

template <
typename Class,
typename... Extra,
enable_if_t<Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value, int>
= 0>
template <typename Class,
typename... Extra,
enable_if_t<Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value,
int> = 0>
static void execute(Class &cl, const Extra &...extra) {
cl.def(
"__init__",
Expand All @@ -345,11 +343,10 @@ struct constructor {
// Implementing class for py::init_alias<...>()
template <typename... Args>
struct alias_constructor {
template <
typename Class,
typename... Extra,
enable_if_t<Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value, int>
= 0>
template <typename Class,
typename... Extra,
enable_if_t<Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value,
int> = 0>
static void execute(Class &cl, const Extra &...extra) {
cl.def(
"__init__",
Expand Down
6 changes: 2 additions & 4 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ using ExceptionTranslator = void (*)(std::exception_ptr);
# define PYBIND11_TLS_KEY_INIT(var) \
_Pragma("clang diagnostic push") /**/ \
_Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \
Py_tss_t var \
= Py_tss_NEEDS_INIT; \
Py_tss_t var = Py_tss_NEEDS_INIT; \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
# define PYBIND11_TLS_KEY_INIT(var) \
_Pragma("GCC diagnostic push") /**/ \
_Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \
Py_tss_t var \
= Py_tss_NEEDS_INIT; \
Py_tss_t var = Py_tss_NEEDS_INIT; \
_Pragma("GCC diagnostic pop")
#else
# define PYBIND11_TLS_KEY_INIT(var) Py_tss_t var = Py_tss_NEEDS_INIT;
Expand Down
6 changes: 2 additions & 4 deletions include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ class handle : public detail::object_api<handle> {
detail::enable_if_t<detail::all_of<detail::none_of<std::is_base_of<handle, T>,
detail::is_pyobj_ptr_or_nullptr_t<T>>,
std::is_convertible<T, PyObject *>>::value,
int>
= 0>
int> = 0>
// NOLINTNEXTLINE(google-explicit-constructor)
handle(T &obj) : m_ptr(obj) {}

Expand Down Expand Up @@ -1694,8 +1693,7 @@ class str : public object {
template <typename T,
detail::enable_if_t<!std::is_base_of<object, detail::remove_cvref_t<T>>::value
&& std::is_constructible<handle, T>::value,
int>
= 0>
int> = 0>
explicit str(T &&h) : object(raw_str(handle(std::forward<T>(h)).ptr()), stolen_t{}) {
if (!m_ptr) {
throw error_already_set();
Expand Down
3 changes: 1 addition & 2 deletions tests/test_pytypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,7 @@ TEST_SUBMODULE(pytypes, m) {
static_class.def(py::init());
static_class.attr_with_type_hint<py::typing::ClassVar<float>>("x") = 1.0;
static_class.attr_with_type_hint<py::typing::ClassVar<py::typing::Dict<py::str, int>>>(
"dict_str_int")
= py::dict();
"dict_str_int") = py::dict();

struct Instance {};
auto instance = py::class_<Instance>(m, "Instance", py::dynamic_attr());
Expand Down
3 changes: 1 addition & 2 deletions tests/test_virtual_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ struct AdderBase {
using DataVisitor = std::function<void(const Data &)>;

virtual void
operator()(const Data &first, const Data &second, const DataVisitor &visitor) const
= 0;
operator()(const Data &first, const Data &second, const DataVisitor &visitor) const = 0;
virtual ~AdderBase() = default;
AdderBase() = default;
AdderBase(const AdderBase &) = delete;
Expand Down
Loading