devlib icon indicating copy to clipboard operation
devlib copied to clipboard

Unwieldy Target subclasses signature improvements

Open douglas-raillard-arm opened this issue 11 months ago • 0 comments

Target subclasses have grown somewhat unwieldy over the years in 2 ways:

  • Some parameters logically related are spread apart in the signature due to the order in which they were introduced in the code.
  • A lot of these parameters are shoveled around to super().__init__(), making adding new parameters more error prone than it should be and duplicating default values for those everywhere.

To address that, moving most arguments to being keyword-only would ensure:

  1. the user code stays sane
  2. Target subclasses could mostly be forwarding **kwargs to the super class where possible.
  3. We would not duplicate default values everywhere anymore

The main cons are:

  1. It's an API breaking change. However:
    • I would suspect the vast majority of user code either does not set those parameters or already uses keyword arguments syntax
    • Once the user code is fixed, the user code is backward and forward compatible so they can still switch to older devlib versions if needed.
    • This can be done after a grace period where we emit a DeprecationWarning when any positional argument is used.
  2. Depending on how the documentation is dealt with, this can affect the visible signature. However:
    • The current style of doc is completely separate from the code and would not be affected.
    • The equivalent docstring style would not really be affected, and decorators can be implemented to make the signature look better (I did in LISA and it works fine).
    • There is a reasonable chance that type annotation these days can help recover decent autocompletion on a **kwargs signature, but I'd need to check the details.

douglas-raillard-arm avatar Feb 13 '25 10:02 douglas-raillard-arm