since you are using kwargs  it would help to know what the possible args are that you support  i have discovered instance id  key and value  also it appears that either a  metadata must be provided or  b  metadata key and instance id must be provided  or c  a key and a value must be provided  but there is more i am curious why you chose kwargs for these three while you have named args for metadata and metadata key which are both defaulted to none  why not  this may be a   dumb   suggestion  so my apologies if it is  make the signature just init self  context kwargs and glean the rest as you go 