Skip to main content

Posts

Showing posts with the label python

Python Static Code Analysis in 2026: Ruff, Bandit, Pylint and Mypy for Safer Code

Updated in 2026: this article was originally written in 2020 and focused mainly on Prospector and Bandit. The updated version keeps that original idea, but adds a more modern Python static analysis workflow using Ruff, Bandit, Mypy and Pylint. Python scripts are dangerous when they become invisible. Not dangerous in a movie-hacker way. Dangerous in the boring real-world way. A small script starts as a quick helper. Then it ends up running from cron. Then it touches backups, logs, Docker containers, firewall data, API keys, file permissions, or some random directory on a Linux server. Months later, nobody remembers exactly what it does, but everyone hopes it keeps working. That is where Python static code analysis is useful. Static analysis checks code before you run it. It can catch common bugs, insecure patterns, style problems, type mistakes, unused imports, dangerous function calls and other issues that are easy to miss when a script is small and “just works”. In the or...