From 42b54507eaa23b265e8de144aeacb2455a837486 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 20 Jul 2022 12:02:20 -0400 Subject: [PATCH] chore: use explicit defaulting in pyobject macros (#4017) * Use equals default in pyobject macros * Remove extra semicolon * Update clang-tidy equals-default rule to not ignore macros * Fix formatting * One last formatting change --- .clang-tidy | 2 ++ include/pybind11/numpy.h | 2 +- include/pybind11/pytypes.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d945a4a2..23018386 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -63,6 +63,8 @@ Checks: | -bugprone-unused-raii, CheckOptions: +- key: modernize-use-equals-default.IgnoreMacros + value: false - key: performance-for-range-copy.WarnOnAllAutoCopies value: true - key: performance-inefficient-string-concatenation.StrictMode diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 0291b02d..4f82f1ec 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -537,7 +537,7 @@ PYBIND11_NAMESPACE_END(detail) class dtype : public object { public: - PYBIND11_OBJECT_DEFAULT(dtype, object, detail::npy_api::get().PyArrayDescr_Check_); + PYBIND11_OBJECT_DEFAULT(dtype, object, detail::npy_api::get().PyArrayDescr_Check_) explicit dtype(const buffer_info &info) { dtype descr(_dtype_from_pep3118()(pybind11::str(info.format))); diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index ad5edfed..7a731e22 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -1283,7 +1283,7 @@ public: #define PYBIND11_OBJECT_CVT_DEFAULT(Name, Parent, CheckFun, ConvertFun) \ PYBIND11_OBJECT_CVT(Name, Parent, CheckFun, ConvertFun) \ - Name() : Parent() {} + Name() = default; #define PYBIND11_OBJECT_CHECK_FAILED(Name, o_ptr) \ ::pybind11::type_error("Object of type '" \ @@ -1306,7 +1306,7 @@ public: #define PYBIND11_OBJECT_DEFAULT(Name, Parent, CheckFun) \ PYBIND11_OBJECT(Name, Parent, CheckFun) \ - Name() : Parent() {} + Name() = default; /// \addtogroup pytypes /// @{