MSS icon indicating copy to clipboard operation
MSS copied to clipboard

lookup test for "does not match signature of the base method in ..."

Open ReimarBauer opened this issue 1 year ago • 4 comments

I've just seen a few warnings by Pycharm about

"Signature of method ... does not match signature of the base method ..."

e.g. closeEvent, changeEvent, moveEvent

a warning is not an error. I think we should lookup those and try to use the origin signature. When it is wanted as it is, we should flag them.

This can give a hint for an API change of our dependencies.

ReimarBauer avatar Sep 27 '24 09:09 ReimarBauer

What linter does pycharm use to generate these warnings? Can we incorporate it into our lint workflow?

matrss avatar Sep 27 '24 10:09 matrss

unfortunantely it looks like this one is built-in.

collected informations by perplexity. https://www.perplexity.ai/search/how-does-pycharm-do-the-test-f-XDcwnYHfR3KTtG0K.ATO2w#1

PyCharm does not use a specific linter to check for the Liskov Substitution Principle (LSP). Instead, PyCharm's built-in code inspection and analysis tools perform signature matching and type checking to help identify potential violations of LSP.

ReimarBauer avatar Sep 30 '24 07:09 ReimarBauer

Hi @ReimarBauer , I believe the issue is a method signature mismatch in changeEvent. The parameter should have a defined type, like this: def changeEvent(self, event: QEvent):

anj20 avatar Jan 31 '25 05:01 anj20

Pycharm suggests a signature change to

def closeEvent(self, event, **kwargs)

because of QWidget.__init__,

def __init__(self, parent, QWidget=None, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
        pass

Qwidget.QMainWindow

    def __init__(self, parent, QWidget=None, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
        pass

the issue here about is find a way like pycharm does to find those problems and keep them fixed.

Of course we can follow the advice of Pycharm and clear these warnings. I am not sure if we easily can do have a test.

ReimarBauer avatar Jan 31 '25 09:01 ReimarBauer