Rasc
Rasc

Reputation: 43

How to disable pylint error message for a specific file?

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.

Upvotes: 4

Views: 5207

Answers (1)

Or b
Or b

Reputation: 816

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

Upvotes: 7

Related Questions