Data Science In Action

Data Science In Action

What is Python Lint?

Why Your Python Code is a Mess and How Linting Fixes It?

Engy Fouda's avatar
Engy Fouda
May 01, 2026
∙ Paid

We’ll walk through setting up a linter step by step, with screenshots showing every click. By the end, you’ll have your code automatically checking itself for mistakes.


The Problem You Didn’t Know You Had

You’ve written some Python code. It works. You run it, and boom, it produces the right output. So you think you’re done, right?

Not quite.

Here’s what you can’t see yet: your code is probably littered with small inconsistencies and potential bugs that Python doesn’t care about, but that will bite you later. Maybe you’re using a variable you never defined. Maybe you have extra spaces in weird places. Maybe you’re using an old library function that’s been replaced. Maybe you have unused imports cluttering up your file.

These aren’t errors; Python won’t crash because of them. But they’re code smell. They make your code harder to read, harder to debug, and more prone to actual bugs.

That’s where linting comes in.

A linter is like a spell-checker for your code. It reads through your Python files and flags potential problems before you even try to run them. It catches mistakes you can’t see, enforces consistent style, and automatically helps you write cleaner code.

And the best part? Once you set it up (which takes 5 minutes), you’ll never think about it again; it just works in the background.

Data Science In Action is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.


What Exactly Does a Linter Check?

Before we get our hands dirty, let me show you what linters actually catch. They check for things like:

Syntax issues:

  • Using a variable you forgot to define

  • Missing colons or parentheses

  • Indentation that’s off by one space; Python is picky!

Code quality issues:

  • Unused imports (you imported something but never used it)

  • Unused variables (same problem, different line)

  • Lines that are too long (make code hard to read)

  • Inconsistent spacing or naming conventions

Potential bugs:

  • Variables that shadow built-in functions

  • Logic that could fail at runtime

  • Code that’s unreachable (dead code)

Style inconsistencies:

  • Mixing tabs and spaces: a Python nightmare

  • Inconsistent indentation

  • Inconsistent naming conventions (should it be my_variable or myVariable?)

Most of these won’t stop your code from running. But they’ll confuse future you or your team, and they make code harder to maintain.

User's avatar

Continue reading this post for free, courtesy of Engy Fouda.

Or purchase a paid subscription.
© 2026 Engy Fouda · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture