Gaweng Tan’s Post

𝐃𝐞𝐯𝐎𝐩𝐬 𝟏𝟎𝟏 𝐟𝐨𝐫 𝐏𝐲𝐭𝐡𝐨𝐧𝐢𝐬𝐭𝐚𝐬 🐍 | 𝐖𝐞𝐞𝐤 𝟐: 𝐒𝐭𝐨𝐩 𝐏𝐮𝐬𝐡𝐢𝐧𝐠 "𝐁𝐫𝐨𝐤𝐞𝐧" 𝐂𝐨𝐝𝐞 Last week, we talked about CI pipelines. But why wait for the pipeline to fail when you can catch errors before you even hit git push? 💡 𝐓𝐡𝐞 𝐅𝐚𝐜𝐭: Pre-commit hooks allow you to run automated checks locally during your git commit process. If the checks fail, the commit is blocked. Why this is a game-changer for your workflow: ✅ No More "Fix Linting" Commits Tired of seeing "fix linting" or "format code" in your git history? Tools like "ruff check" and "ruff format" run automatically. Your repo stays clean, 100% of the time. ✅ Beyond Just Python It’s not just for .py files. You can automatically format YAML configs, check JSON syntax, or even strip large data files before they accidentally enter your history. ✅ Instant Feedback Loop Instead of waiting 3 minutes for a CI runner, you get feedback in 0.5 seconds. It forces you to fix issues while the code is still fresh in your mind. 🛠️ 𝐏𝐫𝐨 𝐓𝐢𝐩: Use the pre-commit framework. A simple .pre-commit-config.yaml is all you need to orchestrate Ruff, MyPy, or even Secret-Detection (to prevent pushing API keys). 𝐓𝐡𝐞 𝐁𝐨𝐭𝐭𝐨𝐦 𝐋𝐢𝐧𝐞: Shifting your quality checks "left" (closer to the dev) saves time, reduces CI costs, and makes you a more disciplined engineer. #Python #DevOps #Git #PreCommit #Ruff #SoftwareEngineering #CleanCode

To view or add a comment, sign in

Explore content categories