Suppressing Specific PyLint Errors
After seeing some examples for opinionated warting and error messages, this lesson teaches you how you can suppress them using PyLint hints or the pylintrc
file.
00:00
All right, so what you can do in this case is you can add a hint for Pylint, and that usually takes the form of a Python comment. So in this case, you could go #pylint
, colon (:
), and then you can go disable=
, and then you want to put the error message or the error type that we saw here.
00:28
In this case it will be unused-argument
. I want to suppress that. And I’m going to zoom out for a minute so you can see what this looks like. So, that’s the hint for the Pylint executable.
00:41 So now when I lint this code again, it ignored this error. And actually, here, we’re going to ignore this other error as well and we’re going to put that on the whole class,
00:53
disable
equals… boom. And now…
00:58
Okay, we did great, right? We suppressed a bunch of errors, ha, and now our code is perfect! Just perfect Python code. I mean, that’s obviously, like, not how this works and you may or may not like how these Pylint hints or annotations, how they’re cluttering up your code. So the other route you can go, you can create a pylintrc
file that stores some of these settings per project, or even globally. And that makes it a lot easier to manage them and you can add that to your source repository for a project, and that way you can control how Pylint checks your code and the feedback it gives you.
Become a Member to join the conversation.
ChrisF on May 27, 2019
Great course thanks Dan.
I am just doing a little project with Open CV and I had 20 + error messages saying it is not a member, so I have just used this trick and now there is none.