Description
Question
I have a model superclass called MaintainedModel
. The latest version of superlinter gives me an unexpected-keyword-arg
error about a call to an overridden method inside another overridden method. There are maybe a dozen such calls in the class, but only one triggers the linter error.
I believe I understand why I get the error about the one call, but I don't know how to satisfy the linter. I think it's because the overridden method creates an instance via a super()-method call. The linter, in that context, doesn't know about the keyword args I added in the other overridden method. To (over-)simplify it, it's basically this:
def from_db(self):
instance = super().from_db()
instance.save(custom_arg=whatever). # unexpected-keyword-arg
I tried adding a typehint to the instance, but that did not prevent the error.
I have more specifics in the following stack post:
The call to save does work and my override of save()
gets the custom args. How do I tell pylint that the args are OK?
Documentation for future user
https://pylint.readthedocs.io/en/latest/user_guide/messages/error/unexpected-keyword-arg.html
Additional context
I asked on this stack post: https://stackoverflow.com/questions/78645414/1-out-of-many-calls-to-overridden-django-model-save-generates-a-pylint-unex
and I was just advised to have pylint ignore the call to save, but I'd like to either change the code to do things "properly" or figure out how to correctly typehint the code.
EDIT: Oh, another important piece of info (and maybe this answers my question?) is that my override of save()
doesn't declare the arts in the signature. It just pops them off of kwargs
before calling super().save(*args, **kwargs)
. Perhaps adding them to the signature will satisfy it? But none of the other save calls in the class ellicit the error, so I felt like maybe that's not going to fix it?