Skip to content

Commit

Permalink
feat: allow annotate methods with pos_only when only have the `self…
Browse files Browse the repository at this point in the history
…` argument
  • Loading branch information
XuehaiPan committed Oct 9, 2024
1 parent af67e87 commit 567000e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,12 @@ class cpp_function : public function {
{
constexpr bool has_kw_only_args = any_of<std::is_same<kw_only, Extra>...>::value,
has_pos_only_args = any_of<std::is_same<pos_only, Extra>...>::value,
has_arg_annotations = any_of<is_keyword<Extra>...>::value;
has_arg_annotations = any_of<is_keyword<Extra>...>::value,
has_is_method = any_of<std::is_same<is_method, Extra>...>::value;
static_assert(has_arg_annotations || !has_kw_only_args,
"py::kw_only requires the use of argument annotations");
static_assert(has_arg_annotations || !has_pos_only_args,
static_assert(has_arg_annotations || !has_pos_only_args
|| (has_is_method /* method has at least one argument `self` */),
"py::pos_only requires the use of argument annotations (for docstrings "
"and aligning the annotations to the argument)");

Expand Down

0 comments on commit 567000e

Please sign in to comment.