• Jason Rhinelander's avatar
    Fix py::kw_only when used before the first arg of a method (#3488) · 673b4be3
    Jason Rhinelander authored
    * Fix py::kw_only when used before the first arg of a method
    
    The implicit space for the `self` argument isn't added until we hit the
    first argument, but this wasn't being done for kw_only or pos_only, and
    so a kw_only before the first argument would break.
    
    This fixes it by properly checking whether we need to add the self arg.
    
    (The pos_only issue here was extremely mild -- you didn't get the `/` in
    the docstring, but AFAICT it has no other effect since there are no
    meaningful arguments before it anyway).
    
    * Style changes
    
    - rename check_have_self_arg -> append_self_arg_if_needed
    
    - move the argument name inline comments before the args instead of
      after
    673b4be3
test_kwargs_and_defaults.cpp 8.3 KB