Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 22, 2025
1 parent 4e85837 commit 89d505f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
16 changes: 7 additions & 9 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1333,14 +1333,12 @@ struct function_record;
struct argument_record;

// forward declaration (definition in pybind11.h)
std::string generate_signature(
const char *text,
function_record *rec,
const std::type_info *const *types,
size_t &type_index,
size_t &arg_index,
const bool is_annotation
);
std::string generate_signature(const char *text,
function_record *rec,
const std::type_info *const *types,
size_t &type_index,
size_t &arg_index,
const bool is_annotation);

// Declared in pytypes.h:
template <typename T, enable_if_t<!is_pyobject<T>::value, int>>
Expand All @@ -1366,7 +1364,7 @@ str_attr_accessor object_api<D>::attr_with_type_hint(const char *key) const {
const char *text = make_caster<T>::name.text;

size_t _ = 0;
ann[key] = generate_signature(text,0,0,_,_, true);
ann[key] = generate_signature(text, 0, 0, _, _, true);
return {derived(), key};
}

Expand Down
21 changes: 10 additions & 11 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,12 @@ inline std::string replace_newlines_and_squash(const char *text) {
return result.substr(str_begin, str_range);
}


inline std::string generate_signature(
const char *text,
detail::function_record *rec,
const std::type_info *const *types,
size_t &type_index,
size_t &arg_index,
const bool is_annotation = false
){
inline std::string generate_signature(const char *text,
detail::function_record *rec,
const std::type_info *const *types,
size_t &type_index,
size_t &arg_index,
const bool is_annotation = false) {
/* Generate a proper function signature */
std::string signature;
bool is_starred = false;
Expand Down Expand Up @@ -199,7 +196,8 @@ inline std::string generate_signature(
// For named arguments (py::arg()) with noconvert set, return value type is used.
++pc;
if (!is_return_value.top()
&& (is_annotation || !(arg_index < rec->args.size() && !rec->args[arg_index].convert))) {
&& (is_annotation
|| !(arg_index < rec->args.size() && !rec->args[arg_index].convert))) {
while (*pc != '\0' && *pc != '@') {
signature += *pc++;
}
Expand Down Expand Up @@ -566,7 +564,8 @@ class cpp_function : public function {
#endif

size_t type_index = 0, arg_index = 0;
std::string signature = detail::generate_signature(text, rec, types, type_index, arg_index);
std::string signature
= detail::generate_signature(text, rec, types, type_index, arg_index);

if (arg_index != args - rec->has_args - rec->has_kwargs || types[type_index] != nullptr) {
pybind11_fail("Internal error while parsing type signature (2)");
Expand Down

0 comments on commit 89d505f

Please sign in to comment.