Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Running PyLint on Your Python Code

Now that you have PyLint installed, let’s get our hands on it. In this lesson, you’ll run PyLint on a sample Python script, which is not pretty formatted. You’ll walk through the error messages, what they tell you and how to fix them.

00:00 So, kind of the minimal example for using Pylint is to simply pass it a Python file. And that actually gets you very, very far. In this case, I’m going to go pylint and I’m going to run Pylint on this example file. All right, so this took a short moment, and now we can see all of the feedback that Pylint has for this particular code that you can see here on the left. So in this case, it actually dug up some interesting stuff.

00:33 Essentially, you get several columns here. In the first column, you can see the type of error or problem that was identified, or the type of feedback that Pylint found. In this case, C will stand for code style, and then we’ve got a W for warning, and these different types.

00:48 Some of them will actually be errors where the Python program wouldn’t work, but I guess you could also find that out in a different way. And yeah, here, the second column, it tells you where this problem is located.

01:00 Now, just a word of—well, not really a word of warning, but just some tip here with these. Obviously, this is kind of hard to go back and forth and identify this feedback, you know, like based on the line numbers that get printed out, but there’s a way you can integrate Pylint feedback into your editor, which again, I also highly recommend that you do that.

01:22 If you want to do that with Sublime Text, I’ve got a whole course that shows you how to set up a really awesome and productive setup for Sublime Text that includes Pylint integration and Flake8 integration.

01:34 So you might want to check that out. But basically, you want the SublimeLinter plugin and then the Pylint plugin to get that up and running on Sublime Text. All right, so now back to the feedback we got here in our code.

01:46 Then here, in the next column, you can actually see what it’s talking about. So here, Pylint says, okay, so there’s a piece of code style feedback in line 6, which is over here, and we’re lacking a space. And that’s true, right?

02:03 Like, when you check over here, or it actually also print that out with this kind of inline example here. So this is a bad-whitespace error, and we’re lacking a space character here. And now I fixed that, and when I run Pylint again,

02:20 we don’t get that error message anymore. We don’t get that warning anymore.

Become a Member to join the conversation.