-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to satisfy unexpected-keyword-arg
in derived class override method that creates an instance via a super() method
#9758
Comments
Without the actual implementation/code it will be very hard to help you out. Are you able to share it? |
The code (minus doc string/comments) where the error line is, is in the stack post, though the save override isn't there. I'll paste it all here... Unedited method where the error occurs (the line with call to save()):
The save() override... (I removed the comments, which were a bit cluttery.) Much of this is likely irrelevant to the issue. Probably only the first half dozen lines are useful for this issue. The code is a bit old and is due for a streamline.
There are other various calls to save that do not ellicit any linting error, such as:
|
The entirety of the code is here. |
Question
I have a model superclass called
MaintainedModel
. The latest version of superlinter gives me anunexpected-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:
I tried adding a typehint to the instance, but that did not prevent the error.
I have more specifics in the following stack post:
https://stackoverflow.com/questions/78645414/1-out-of-many-calls-to-overridden-django-model-save-generates-a-pylint-unex
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 ofkwargs
before callingsuper().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?The text was updated successfully, but these errors were encountered: