mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-11 00:40:22 +00:00
maint(clang-tidy): Improve code readability with explicit boolean casts (#3148)
* maint(clang-tidy) Improve code readability * Fix minor typos * Revert optimization that removed test case * Fix comment formatting * Revert another optimization to repro an issue * Remove make_unique since it C++14 and newer only * eformat comments * Fix unsignedness of comparison * Update comment
This commit is contained in:
@@ -318,7 +318,8 @@ protected:
|
||||
a.descr = guarded_strdup(repr(a.value).cast<std::string>().c_str());
|
||||
}
|
||||
|
||||
rec->is_constructor = !strcmp(rec->name, "__init__") || !strcmp(rec->name, "__setstate__");
|
||||
rec->is_constructor
|
||||
= (strcmp(rec->name, "__init__") == 0) || (strcmp(rec->name, "__setstate__") == 0);
|
||||
|
||||
#if !defined(NDEBUG) && !defined(PYBIND11_DISABLE_NEW_STYLE_INIT_WARNING)
|
||||
if (rec->is_constructor && !rec->is_new_style_constructor) {
|
||||
@@ -1131,7 +1132,8 @@ protected:
|
||||
pybind11_fail("generic_type: cannot initialize type \"" + std::string(rec.name) +
|
||||
"\": an object with that name is already defined");
|
||||
|
||||
if (rec.module_local ? get_local_type_info(*rec.type) : get_global_type_info(*rec.type))
|
||||
if ((rec.module_local ? get_local_type_info(*rec.type) : get_global_type_info(*rec.type))
|
||||
!= nullptr)
|
||||
pybind11_fail("generic_type: type \"" + std::string(rec.name) +
|
||||
"\" is already registered!");
|
||||
|
||||
@@ -1209,8 +1211,9 @@ protected:
|
||||
void def_property_static_impl(const char *name,
|
||||
handle fget, handle fset,
|
||||
detail::function_record *rec_func) {
|
||||
const auto is_static = rec_func && !(rec_func->is_method && rec_func->scope);
|
||||
const auto has_doc = rec_func && rec_func->doc && pybind11::options::show_user_defined_docstrings();
|
||||
const auto is_static = (rec_func != nullptr) && !(rec_func->is_method && rec_func->scope);
|
||||
const auto has_doc = (rec_func != nullptr) && (rec_func->doc != nullptr)
|
||||
&& pybind11::options::show_user_defined_docstrings();
|
||||
auto property = handle((PyObject *) (is_static ? get_internals().static_property_type
|
||||
: &PyProperty_Type));
|
||||
attr(name) = property(fget.ptr() ? fget : none(),
|
||||
@@ -2220,8 +2223,8 @@ inline function get_type_override(const void *this_ptr, const type_info *this_ty
|
||||
Unfortunately this doesn't work on PyPy. */
|
||||
#if !defined(PYPY_VERSION)
|
||||
PyFrameObject *frame = PyThreadState_Get()->frame;
|
||||
if (frame && (std::string) str(frame->f_code->co_name) == name &&
|
||||
frame->f_code->co_argcount > 0) {
|
||||
if (frame != nullptr && (std::string) str(frame->f_code->co_name) == name
|
||||
&& frame->f_code->co_argcount > 0) {
|
||||
PyFrame_FastToLocals(frame);
|
||||
PyObject *self_caller = dict_getitem(
|
||||
frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
|
||||
|
||||
Reference in New Issue
Block a user