Skip to content

Introduction to Code Linting

What linting is

Linting is static analysis that flags issues like:

  • unused imports/variables
  • suspicious logic
  • inconsistent style
  • complexity / maintainability issues

Linting runs without executing your code.

Linting vs formatting vs type checking

  • Linting: “this looks wrong / risky / inconsistent”
  • Formatting: “make code look consistent” (e.g., Black)
  • Type checking: “types don’t match” (e.g., Mypy)

Diagram: quality tools overview

diagram Diagram mermaid

Why linting matters

  • catches bugs before runtime
  • keeps large codebases consistent
  • makes PR reviews faster

Visualize it

Source code typically passes through a formatter, a linter, and a type checker before a commit is allowed through the quality gate.

diagram Code Quality Gate mermaid
Source code passes through formatting, linting, and type checking before a commit is allowed.

🧪 Try It Yourself

Exercise 1 – Write a unittest TestCase

Exercise 2 – assertRaises

Exercise 3 – setUp and tearDown

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did