Skip to content

Commit 9a1e2ec

Browse files
style: pre-commit fixes
1 parent 987f07e commit 9a1e2ec

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

include/pybind11/cast.h

+27-27
Original file line numberDiff line numberDiff line change
@@ -149,39 +149,39 @@ struct type_caster<T, enable_if_t<std::is_arithmetic<T>::value && !is_std_char_t
149149
}
150150
} else {
151151
#if !defined(PYPY_VERSION)
152-
auto index_check = [](PyObject *o) { return PyIndex_Check(o); };
152+
auto index_check = [](PyObject *o) { return PyIndex_Check(o); };
153153
#else
154-
// In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`,
155-
// while CPython only considers the existence of `nb_index`/`__index__`.
156-
auto index_check = [](PyObject *o) { return hasattr(o, "__index__"); };
154+
// In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`,
155+
// while CPython only considers the existence of `nb_index`/`__index__`.
156+
auto index_check = [](PyObject *o) { return hasattr(o, "__index__"); };
157157
#endif
158-
if (PyFloat_Check(src.ptr())
159-
|| (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) {
160-
return false;
161-
}
158+
if (PyFloat_Check(src.ptr())
159+
|| (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) {
160+
return false;
161+
}
162162

163-
handle src_or_index = src;
164-
// PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls.
163+
handle src_or_index = src;
164+
// PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls.
165165
#if defined(PYPY_VERSION)
166-
object index;
167-
if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr())
168-
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
169-
if (!index) {
170-
PyErr_Clear();
171-
if (!convert)
172-
return false;
173-
} else {
174-
src_or_index = index;
166+
object index;
167+
if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr())
168+
index = reinterpret_steal<object>(PyNumber_Index(src.ptr()));
169+
if (!index) {
170+
PyErr_Clear();
171+
if (!convert)
172+
return false;
173+
} else {
174+
src_or_index = index;
175+
}
175176
}
176-
}
177177
#endif
178-
if PYBIND11_IF_CONSTEXPR (std::is_unsigned<py_type>::value) {
179-
py_value = as_unsigned<py_type>(src_or_index.ptr());
180-
} else { // signed integer:
181-
py_value = sizeof(T) <= sizeof(long)
182-
? (py_type) PyLong_AsLong(src_or_index.ptr())
183-
: (py_type) PYBIND11_LONG_AS_LONGLONG(src_or_index.ptr());
184-
}
178+
if PYBIND11_IF_CONSTEXPR (std::is_unsigned<py_type>::value) {
179+
py_value = as_unsigned<py_type>(src_or_index.ptr());
180+
} else { // signed integer:
181+
py_value = sizeof(T) <= sizeof(long)
182+
? (py_type) PyLong_AsLong(src_or_index.ptr())
183+
: (py_type) PYBIND11_LONG_AS_LONGLONG(src_or_index.ptr());
184+
}
185185
}
186186

187187
// Python API reported an error

include/pybind11/pybind11.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ inline str enum_name(handle arg) {
20112011
struct enum_base {
20122012
enum_base(const handle &base, const handle &parent) : m_base(base), m_parent(parent) {}
20132013

2014-
template<bool is_arithmetic, bool is_convertible>
2014+
template <bool is_arithmetic, bool is_convertible>
20152015
PYBIND11_NOINLINE void init() {
20162016
m_base.attr("__entries") = dict();
20172017
auto property = handle((PyObject *) &PyProperty_Type);

0 commit comments

Comments
 (0)