Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable pylint error message for a specific file?

Tags:

python

pylint

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.

like image 513
Rasc Avatar asked Sep 05 '25 03:09

Rasc


1 Answers

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

like image 157
Or b Avatar answered Sep 07 '25 15:09

Or b