Pybind11: [API] Rename py::kwonly to py::kw_only

Created on 19 Aug 2020  路  7Comments  路  Source: pybind/pybind11

The py::kwonly() feature is great, but the naming is not very consistent, I believe. It has not been in a released version of pybind11 yet, so I think we can safely change it to py::kw_only()? Would that be a good idea? (see, for example, py::is_final(), which was also recently added, or py::module_local(), py::buffer_protocol(), etc.).

policy

All 7 comments

I assume kwonly was meant to match kwargs?
A quick search shows that both are used, kw_only notably by attrs, but kwonlyargs by Python itself in the inspect module.

More important to me: I did notice the signature doesn't contain a *. Should we try to fix that? (happy to make a PR)

The signature should, yes. I'd like to have a pos_only and / from Python 3.8 too, honestly. Don't think it would be a hard addition.

It could have been done that way; if there's a good reason, we can keep it that way. That's why I've assigned @wjakob , since it's an API choice. **kwargs is a common, making that a common thing to type in Python, but I think py::kw_only() is more like the other pybind11 tags. But would be happy with either choice as long as it's a conscious decision.

I very slightly lean towards kw_only given the consistency with the other tags @henryiii mentioned, but I don't have a strong opinion at all. If anyone champions the current naming then that would be fine as well. We could vote? :)

@skoslowski @jagerman

I prefer kw_only, mostly for consistency. Especially considering a potential pos_only flag - posonly would be really hard to read...

Weak preference for kw_only over kwonly

Seems like py:kw_only is winning. I've added it to the PR above, but it is a separate comment so still could be dropped easily.

Was this page helpful?
0 / 5 - 0 ratings