4

To receive an event in PyQT, you have to override the event-handler.

For example:

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

    def resizeEvent(self, event: QResizeEvent):
        super().resizeEvent(event)

In this case, pylint shows error C0103 invalid-name:

Method name "resizeEvent" doesn't conform to snake_case naming style

Pylint is right, but you cannot rename the method, else I will not get the event.

But I don't want to disable these pylint warning for the whole project. Is it possible to deactivate the warning locally? Or can I mark the method as @override?

Thanks.

Or b
  • 666
  • 1
  • 5
  • 22
Rasc
  • 43
  • 1
  • 3
  • Does [this](https://stackoverflow.com/a/66784120/13145954) answer your question? – Seon Apr 20 '21 at 15:51
  • I edited your question to include your error code and message name. add these details next time. – Or b Apr 21 '21 at 19:31

1 Answers1

4

I know you can disable a specific pylint message for an entire file. So for error C0103 (invlaid-name) you could write at the top of your module:

# pylint: disable=invalid-name

the message will not show for this file.

Also you could disable a message for a specific line adding this syntax after this line, in your example it'd be:

def resizeEvent(self, event: QResizeEvent):  # pylint: disable=invalid-name

Similar answer here

Or b
  • 666
  • 1
  • 5
  • 22