Linters versus formatters

Beginner Accelerating numerics & developer hygiene
Created by Pavel · 29.04.2026 at 19:11 UTC

Formatters (Black, isort) rewrite layout—whitespace, line breaks, import order—without changing semantics. Linters (Ruff/flake8/pylint rules) flag suspicious patterns: unused variables, mutable defaults, complexity.

CI pipelines typically run format check (black --check) and lint (ruff) alongside tests. They do not replace tests or types—they reduce noise and catch footguns early.

Black documentation: [1].


Sources

University approvals: 0
Tasks
Question 1

Black primarily:

Hint

Formatter vs linter.

Question 2

Which tool category is more concerned with semantic smells like unused imports or mutable default arguments?

Hint

Bug patterns vs whitespace.

Question 3

squash_spaces(s) returns ' '.join(s.split()) (normalise internal whitespace, trim ends).

Hint

split/join idiom.

Starter code is prefilled; replace TODO blocks with your solution.
1 test case will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Card Info
  • Topic: Accelerating numerics & developer hygiene
  • Difficulty: Beginner
  • Completed: 0 users
Creator
Pavel
Pavel