The RBTools codebase is old, and we have a lot of code that doesn't
quite follow best practices. These include functions that take a whole
lot of keyword arguments, but with calls passing values as positional
Python 3 allows us to define keyword-only arguments, which can help us
clean things up, but as we aim to provide backwards-compatibility during
deprecation phases, we can't just simply use them.
This change introduces a decorator to help with this.
rbtools.deprecation.deprecate_non_keyword_only_args() can be used for
any function taking keyword-only arguments. Any call that supplies such
an argument via a positional argument value will trigger a deprecation
warning. The arguments will then be rewritten to pass those in as
We'll want this pattern for other codebases in time. Unfortunately, no
other packages we depend on provide a decorator like this, so we'll need
to maintain it ourselves. (Packages like
debtcollector do not provide
anything for this.). For now, it will remain in RBTools.