TheSystemDevelopmentKit / inverter

This is a very simple example of a TheSDK Entity submodule
0 stars 1 forks source link

Use keyword arguments instead of variable length argument list #13

Open chiplet opened 2 years ago

chiplet commented 2 years ago

In a recent discussion with @mkosunen it was brought up that keyword arguments **kwargs should be preferred instead of using *args. This project still uses the *args for entity/controller initialization in at least the following locations: https://github.com/TheSystemDevelopmentKit/inverter/blob/c848bb008722caff006b614287c3f558939ff364/inverter/__init__.py#L51 https://github.com/TheSystemDevelopmentKit/inverter/blob/fff15a89a256e3e46f87b15e2ed8111b2722d0f6/inverter/controller.py#L15

mkosunen commented 2 years ago

This is kind of embarassing. I think this is the only occasion where I have done this, the first hack just to get it to work, and it just have not been changed. That first argument is supposed to be parent instance, if it is given.

But you are right, we should change it, and now we shoud figure out how to do it so that the change is backwards compatible and does not break every entity ever written for thesydekick :)

Roenski commented 2 years ago

Could you just use both? Keyword args are named arguments anyways, so they shouldn't break the variable length arguments.

def __init__(self,*arg,**kwargs):