The following snippet is very useful:
sorted(params_set, key=(lambda param: (param.kind.value, (param.default is not param.empty)))
Its purpose is to enable an unsorted or badly-sorted iterable of Parameters to be put easily in an order that would be syntactically correct (1).
But it relies on the value
attributes of the Parameter’s kinds to be integers, or at least orderable, and ordered correctly - which they are, but it’s not documented.
So it could be useful to settle it and document, as a possible minimum, that kind.value
returns an orderable value and what their order is. Or to fully document it as an IntEnum. Although I wouldn’t consider documenting the integer values themselves to be a great idea.
It also seems to be the only purpose of it being an IntEnum at all, which I presume hasn’t been done randomly.
(1) unless one is a defaulted pos-only and another is a required pos-or-kw, but in that case there is no valid ordering anyway.