I am writing a mixin in Python3.8:
class Cloneable:
def change_field(self, **kwargs):
""" Create a new object with only the specified properties changed."""
argdict = {**kwargs, **{key: self.__getattribute__(key) for key in self.__slots__ if
key not in kwargs and key[:2] != '__'}}
return self.__class__(**argdict)
On PyCharm, I get a warning "Unexpected argument" on the last line. This is presumably because of keyword argument unpacking. If this were a function I could include **kwargs
in the function signature, but it's a mixin, and I don't know which __init__
it will be relevant to in advance.
How can I suppress such annoying warnings?